Skip to content

Commit

Permalink
SNOW-1015031: ESLint no-unused-vars rule (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pbulawa authored Jan 23, 2024
1 parent 9affcd0 commit 0a1818f
Show file tree
Hide file tree
Showing 60 changed files with 268 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
'no-prototype-builtins': ['error'],
'no-redeclare': ['error'],
'no-undef': ['error'],
'no-unused-vars': ['warn'],
'no-unused-vars': ['error'],
'no-useless-catch': ['error'],
'no-useless-escape': ['error'],
'no-var': ['error'],
Expand Down
3 changes: 1 addition & 2 deletions lib/agent/https_ocsp_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) 2015-2019 Snowflake Computing Inc. All rights reserved.
*/

const Util = require('../util');
const HttpsAgent = require('https').Agent;
const SocketUtil = require('./socket_util');

Expand All @@ -15,7 +14,7 @@ const SocketUtil = require('./socket_util');
* @constructor
*/
function HttpsOcspAgent(options) {
const agent = HttpsAgent.apply(this, arguments);
const agent = HttpsAgent.apply(this, [options]);
agent.createConnection = function (port, host, options) {
// make sure the 'options' variables references the argument that actually
// contains the options
Expand Down
1 change: 1 addition & 0 deletions lib/agent/socket_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ exports.variables = variables;
*
* @param {Object} socket
* @param {String} host
* @param {Object} agent
* @param {Object} mock
*
* @returns {Object}
Expand Down
4 changes: 1 addition & 3 deletions lib/authentication/auth_default.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function AuthDefault(password) {
body['data']['PASSWORD'] = password;
};

this.authenticate = async function (authenticator, serviceName, account, username) {
return;
};
this.authenticate = async function () {};
}

module.exports = AuthDefault;
4 changes: 1 addition & 3 deletions lib/authentication/auth_oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function AuthOauth(token) {
body['data']['TOKEN'] = token;
};

this.authenticate = async function (authenticator, serviceName, account, username) {
return;
};
this.authenticate = async function () {};
}

module.exports = AuthOauth;
2 changes: 1 addition & 1 deletion lib/authentication/auth_web.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { rest } = require('../global_config');
* Creates an external browser authenticator.
*
* @param {Object} connectionConfig
* @param {Object} ssoUrlProvider
* @param {Object} httpClient
* @param {module} webbrowser
*
* @returns {Object}
Expand Down
4 changes: 1 addition & 3 deletions lib/connection/bind_uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
*/
const Logger = require('../logger');

const Readable = require('stream').Readable;
const fs = require('fs');

const Statement = require('./statement');
const fileCompressionType = require('.././file_transfer_agent/file_compression_type');

const STAGE_NAME = 'SYSTEM$BIND';
const CREATE_STAGE_STMT = 'CREATE OR REPLACE TEMPORARY STAGE '
Expand Down Expand Up @@ -65,7 +63,7 @@ function BindUploader(options, services, connectionConfig, requestId) {
const putStmt = 'PUT file://' + fileName + '\'' + stageName + '\' overwrite=true auto_compress=false source_compression=gzip';
const uploadFileOptions = {
sqlText: putStmt, fileStream: fileData,
complete: function (err, stmt, rows) {
complete: function (err, stmt) {
if (err) {
Logger.getInstance().debug('err ' + err);
reject(err);
Expand Down
1 change: 0 additions & 1 deletion lib/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
const { v4: uuidv4 } = require('uuid');
const Url = require('url');
const QueryString = require('querystring');
const GSErrors = require('../constants/gs_errors');
const QueryStatus = require('../constants/query_status');

const Util = require('../util');
Expand Down
16 changes: 4 additions & 12 deletions lib/connection/result/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,10 @@ function createFnIsColumnOfType(columnType, columnComparisonFn, scope) {
* post-processed version of the value obtained after casting to Number.
*
* @param {String} rawColumnValue
* @param {Object} column
* @param {Object} context
*
* @returns {Object}
*/
function convertRawNumber(rawColumnValue, column, context) {
function convertRawNumber(rawColumnValue) {
return {
raw: rawColumnValue,
processed: Number(rawColumnValue)
Expand All @@ -251,11 +249,9 @@ function convertRawNumber(rawColumnValue, column, context) {
* version of the value obtained after casting to bigInt
*
* @param rawColumnValue
* @param column
* @param context
* @returns {{processed: bigInt.BigInteger, raw: *}}
*/
function convertRawBigInt(rawColumnValue, column, context) {
function convertRawBigInt(rawColumnValue) {
return {
raw: rawColumnValue,
processed: bigInt(rawColumnValue)
Expand All @@ -267,12 +263,10 @@ function convertRawBigInt(rawColumnValue, column, context) {
* or null).
*
* @param {String} rawColumnValue
* @param {Object} column
* @param {Object} context
*
* @returns {Boolean}
*/
function convertRawBoolean(rawColumnValue, column, context) {
function convertRawBoolean(rawColumnValue) {
let ret;

if ((rawColumnValue === '1') || (rawColumnValue === 'TRUE')) {
Expand Down Expand Up @@ -480,12 +474,10 @@ function convertRawTimestampHelper(
* Converts a raw column value of type Variant to a JavaScript value.
*
* @param {String} rawColumnValue
* @param {Object} column
* @param {Object} context
*
* @returns {Object | Array}
*/
function convertRawVariant(rawColumnValue, column, context) {
function convertRawVariant(rawColumnValue) {
// if the input is a non-empty string, convert it to a json object
if (Util.string.isNotNullOrEmpty(rawColumnValue)) {
try {
Expand Down
2 changes: 1 addition & 1 deletion lib/connection/result/result_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function ResultStream(options) {
chunks[currChunk].on('loadcomplete', onLoadComplete);

// Fire off requests to load all the chunks in the buffer that aren't already loading
let chunk, index, length;
let chunk, index;
for (index = currChunk; index < chunks.length && index <= (currChunk + prefetchSize); index++) {
chunk = chunks[index];
if (!chunk.isLoading()) {
Expand Down
22 changes: 9 additions & 13 deletions lib/connection/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ exports.createContext = function (
function createStatement(
statementOptions, context, services, connectionConfig) {
// call super
BaseStatement.apply(this, arguments);
BaseStatement.apply(this, [statementOptions, context, services, connectionConfig]);
}

/**
Expand Down Expand Up @@ -615,10 +615,8 @@ function BaseStatement(
/**
* Called when the statement request is successful. Subclasses must provide
* their own implementation.
*
* @param {Object} body
*/
context.onStatementRequestSucc = function (body) {
context.onStatementRequestSucc = function () {
};
}

Expand Down Expand Up @@ -686,7 +684,7 @@ function RowStatementPreExec(
connectionConfig) {
Logger.getInstance().debug('RowStatementPreExec');
// call super
BaseStatement.apply(this, arguments);
BaseStatement.apply(this, [statementOptions, context, services, connectionConfig]);

// add the result request headers to the context
context.resultRequestHeaders = buildResultRequestHeadersRow();
Expand Down Expand Up @@ -788,7 +786,7 @@ function createOnStatementRequestSuccRow(statement, context) {
function FileStatementPreExec(
statementOptions, context, services, connectionConfig) {
// call super
BaseStatement.apply(this, arguments);
BaseStatement.apply(this, [statementOptions, context, services, connectionConfig]);

// add the result request headers to the context
context.resultRequestHeaders = buildResultRequestHeadersFile();
Expand Down Expand Up @@ -866,10 +864,8 @@ function StageBindingStatementPreExec(
/**
* Called when the statement request is successful. Subclasses must provide
* their own implementation.
*
* @param {Object} body
*/
context.onStatementRequestSucc = function (body) {
context.onStatementRequestSucc = function () {
//do nothing
};

Expand Down Expand Up @@ -933,7 +929,7 @@ Util.inherits(StageBindingStatementPreExec, BaseStatement);
function StatementPostExec(
statementOptions, context, services, connectionConfig) {
// call super
BaseStatement.apply(this, arguments);
BaseStatement.apply(this, [statementOptions, context, services, connectionConfig]);

// add the result request headers to the context
context.resultRequestHeaders = buildResultRequestHeadersRow();
Expand Down Expand Up @@ -1314,7 +1310,7 @@ this.sendRequest = function (statementContext, onResultAvailable) {
// clone the options
options = Util.apply({}, options);

return new Promise((resolve, reject) => {
return new Promise((resolve) => {
resolve(sf.postAsync(options));
});
};
Expand Down Expand Up @@ -1585,13 +1581,13 @@ function countBinding(binds) {
}

function hasNextResult(statement, context) {
return function (options) {
return function () {
return (context.multiResultIds != null && context.multiCurId + 1 < context.multiResultIds.length);
};
}

function createNextReuslt(statement, context) {
return function (options) {
return function () {
if (hasNextResult(statement, context)) {
context.multiCurId++;
context.queryId = context.multiResultIds[context.multiCurId];
Expand Down
2 changes: 1 addition & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function Core(options) {
*/
this.destroy = function (connection) {
return new Promise((resolve) => {
connection.destroy(function (err, conn) {
connection.destroy(function (err) {
if (err) {
Logger.getInstance().error('Unable to disconnect: ' + err.message);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ function createError(name, options) {

// if the error is not synchronous, add an externalize() method
if (!options.synchronous) {
error.externalize = function (errorCode, errorMessageArgs, sqlState) {
error.externalize = function () {
const propNames =
[
'name',
Expand Down
21 changes: 9 additions & 12 deletions lib/file_transfer_agent/azure_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ function AzureUtil(azure, filestream) {
* @param {String} fileStream
* @param {Object} meta
* @param {Object} encryptionMetadata
* @param {Number} maxConcurrency
*
* @returns {null}
*/
this.uploadFileStream = async function (fileStream, meta, encryptionMetadata, maxConcurrency) {
this.uploadFileStream = async function (fileStream, meta, encryptionMetadata) {
const azureMetadata = {
'sfcdigest': meta['SHA256_DIGEST']
};
Expand Down Expand Up @@ -222,16 +221,14 @@ function AzureUtil(azure, filestream) {
};

/**
* Download the file blob then write the file.
*
* @param {String} dataFile
* @param {Object} meta
* @param {Object} encryptionMetadata
* @param {Number} maxConcurrency
*
* @returns {null}
*/
this.nativeDownloadFile = async function (meta, fullDstPath, maxConcurrency) {
* Download the file blob then write the file.
*
* @param {Object} meta
* @param fullDstPath
*
* @returns {null}
*/
this.nativeDownloadFile = async function (meta, fullDstPath) {
const stageInfo = meta['stageInfo'];
const client = this.createClient(stageInfo);
const azureLocation = this.extractContainerNameAndPath(stageInfo['location']);
Expand Down
7 changes: 3 additions & 4 deletions lib/file_transfer_agent/encrypt_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ function EncryptUtil(encrypt, filestream, temp) {
*
* @returns {Object}
*/
this.encryptFileStream = async function (encryptionMaterial, fileStream,
tmpDir = null, chunkSize = blockSize * 4 * 1024) {
this.encryptFileStream = async function (encryptionMaterial, fileStream) {
// Get decoded key from base64 encoded value
const decodedKey = Buffer.from(encryptionMaterial[QUERY_STAGE_MASTER_KEY], BASE64);
const keySize = decodedKey.length;
Expand Down Expand Up @@ -198,7 +197,7 @@ function EncryptUtil(encrypt, filestream, temp) {
const tempOutputFileName = tmpobj.name;
const tempFd = tmpobj.fd;

await new Promise(function (resolve, reject) {
await new Promise(function (resolve) {
const infile = fs.createReadStream(inFileName, { highWaterMark: chunkSize });
const outfile = fs.createWriteStream(tempOutputFileName);

Expand Down Expand Up @@ -291,7 +290,7 @@ function EncryptUtil(encrypt, filestream, temp) {
// Create decipher with file key, iv bytes, and AES CBC
decipher = crypto.createDecipheriv(AES_CBC, fileKey, ivBytes);

await new Promise(function (resolve, reject) {
await new Promise(function (resolve) {
const infile = fs.createReadStream(inFileName, { highWaterMark: chunkSize });
const outfile = fs.createWriteStream(tempOutputFileName);

Expand Down
4 changes: 2 additions & 2 deletions lib/file_transfer_agent/file_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function FileUtil() {
const baseName = path.basename(fileName);
const gzipFileName = path.join(tmpDir, baseName + '_c.gz');

await new Promise(function (resolve, reject) {
await new Promise(function (resolve) {
// Create gzip object
const gzip = zlib.createGzip();
// Create stream object for reader and writer
Expand Down Expand Up @@ -110,7 +110,7 @@ function FileUtil() {
const bufferSize = fileInfo.size;

let buffer = [];
await new Promise(function (resolve, reject) {
await new Promise(function (resolve) {
// Create reader stream and set maximum chunk size
const infile = fs.createReadStream(fileName, { highWaterMark: chunkSize });
infile.on('data', function (chunk) {
Expand Down
11 changes: 3 additions & 8 deletions lib/file_transfer_agent/gcs_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ const GCS_METADATA_ENCRYPTIONDATAPROP = GCS_METADATA_PREFIX + ENCRYPTIONDATAPROP
const GCS_FILE_HEADER_DIGEST = 'gcs-file-header-digest';
const GCS_FILE_HEADER_CONTENT_LENGTH = 'gcs-file-header-content-length';
const GCS_FILE_HEADER_ENCRYPTION_METADATA = 'gcs-file-header-encryption-metadata';
const CONTENT_CHUNK_SIZE = 10 * 1024;

const HTTP_HEADER_CONTENT_ENCODING = 'Content-Encoding';
const HTTP_HEADER_ACCEPT_ENCODING = 'Accept-Encoding';
const resultStatus = require('./file_util').resultStatus;

const { Storage } = require('@google-cloud/storage');
Expand Down Expand Up @@ -223,11 +221,10 @@ function GCSUtil(httpclient, filestream) {
* @param {String} fileStream
* @param {Object} meta
* @param {Object} encryptionMetadata
* @param {Number} maxConcurrency
*
* @returns {null}
*/
this.uploadFileStream = async function (fileStream, meta, encryptionMetadata, maxConcurrency) {
this.uploadFileStream = async function (fileStream, meta, encryptionMetadata) {
let uploadUrl = meta['presignedUrl'];
let accessToken = null;

Expand Down Expand Up @@ -329,14 +326,12 @@ function GCSUtil(httpclient, filestream) {
/**
* Download the file.
*
* @param {String} dataFile
* @param {Object} meta
* @param {Object} encryptionMetadata
* @param {Number} maxConcurrency
* @param fullDstPath
*
* @returns {null}
*/
this.nativeDownloadFile = async function (meta, fullDstPath, maxConcurrency) {
this.nativeDownloadFile = async function (meta, fullDstPath) {
let downloadUrl = meta['presignedUrl'];
let accessToken = null;
let gcsHeaders = {};
Expand Down
2 changes: 1 addition & 1 deletion lib/file_transfer_agent/local_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const resultStatus = require('./file_util').resultStatus;
* @constructor
*/
function LocalUtil() {
this.createClient = function (stageInfo, useAccelerateEndpoint) {
this.createClient = function () {
return null;
};

Expand Down
Loading

0 comments on commit 0a1818f

Please sign in to comment.