Eslint errors
This commit is contained in:
parent
43481b42e5
commit
014158c968
@ -1,7 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
// jshint ignore:start
|
||||
|
||||
const debug = require('debug')('>');
|
||||
debug.enabled = true;
|
||||
const { promisify } = require('util');
|
||||
@ -129,5 +127,3 @@ async function main () {
|
||||
}
|
||||
|
||||
main().then(() => process.exit(0));
|
||||
|
||||
// jshint ignore:end
|
||||
|
@ -185,7 +185,6 @@ JobFallback.prototype.setFallbackStatus = function (status, job, hasChanged) {
|
||||
};
|
||||
|
||||
JobFallback.prototype.shiftStatus = function (status, hasChanged) {
|
||||
// jshint maxcomplexity: 7
|
||||
if (hasChanged.appliedToFallback) {
|
||||
if (!this.hasNextQueryFromQueries() && (status === JobStatus.DONE || status === JobStatus.FAILED)) {
|
||||
status = this.getLastFinishedStatus();
|
||||
|
@ -40,7 +40,6 @@ QueryFallback.prototype.getNextQuery = function (job) {
|
||||
};
|
||||
|
||||
QueryFallback.prototype.setStatus = function (status, job, previous, errorMesssage) {
|
||||
// jshint maxcomplexity: 9
|
||||
var isValid = false;
|
||||
var appliedToFallback = false;
|
||||
|
||||
|
@ -19,7 +19,6 @@ BinaryFormat.prototype._extractTypeFromName = function (name) {
|
||||
}
|
||||
};
|
||||
|
||||
// jshint maxcomplexity:12
|
||||
BinaryFormat.prototype.transform = function (result, options, callback) {
|
||||
var total_rows = result.rowCount;
|
||||
var rows = result.rows;
|
||||
|
@ -14,7 +14,6 @@ JsonFormat.prototype = new Pg('json');
|
||||
|
||||
JsonFormat.prototype._contentType = 'application/json; charset=utf-8';
|
||||
|
||||
// jshint maxcomplexity:10
|
||||
JsonFormat.prototype.formatResultFields = function (flds) {
|
||||
flds = flds || [];
|
||||
var nfields = {};
|
||||
@ -93,7 +92,6 @@ JsonFormat.prototype.handleQueryRow = function (row, result) {
|
||||
}
|
||||
};
|
||||
|
||||
// jshint maxcomplexity:13
|
||||
JsonFormat.prototype.handleQueryEnd = function (result) {
|
||||
if (this.error && !this._streamingStarted) {
|
||||
this.callback(this.error);
|
||||
|
@ -2,18 +2,18 @@
|
||||
|
||||
var Pg = require('./../pg');
|
||||
|
||||
var svg_width = 1024.0;
|
||||
var svg_height = 768.0;
|
||||
var svg_ratio = svg_width / svg_height;
|
||||
var svgWidth = 1024.0;
|
||||
var svgHeight = 768.0;
|
||||
var svgRatio = svgWidth / svgHeight;
|
||||
|
||||
var radius = 5; // in pixels (based on svg_width and svg_height)
|
||||
var radius = 5; // in pixels (based on svgWidth and svgHeight)
|
||||
|
||||
var stroke_width = 1; // in pixels (based on svg_width and svg_height)
|
||||
var stroke_color = 'black';
|
||||
var strokeWidth = 1; // in pixels (based on svgWidth and svgHeight)
|
||||
var strokeColor = 'black';
|
||||
// fill settings affect polygons and points (circles)
|
||||
var fill_opacity = 0.5; // 0.0 is fully transparent, 1.0 is fully opaque
|
||||
// unused if fill_color='none'
|
||||
var fill_color = 'none'; // affects polygons and circles
|
||||
var fillOpacity = 0.5; // 0.0 is fully transparent, 1.0 is fully opaque
|
||||
// unused if fillColor='none'
|
||||
var fillColor = 'none'; // affects polygons and circles
|
||||
|
||||
function SvgFormat () {
|
||||
this.totalRows = 0;
|
||||
@ -37,11 +37,11 @@ SvgFormat.prototype.getQuery = function (sql, options) {
|
||||
'st_xmax(e)-st_xmin(e) as ew, ' +
|
||||
'st_ymax(e)-st_ymin(e) as eh FROM extent )' +
|
||||
', trans AS ( SELECT CASE WHEN ' +
|
||||
'eh = 0 THEN ' + svg_width +
|
||||
'/ COALESCE(NULLIF(ew,0),' + svg_width + ') WHEN ' +
|
||||
svg_ratio + ' <= (ew / eh) THEN (' +
|
||||
svg_width + '/ew ) ELSE (' +
|
||||
svg_height + '/eh ) END as s ' +
|
||||
'eh = 0 THEN ' + svgWidth +
|
||||
'/ COALESCE(NULLIF(ew,0),' + svgWidth + ') WHEN ' +
|
||||
svgRatio + ' <= (ew / eh) THEN (' +
|
||||
svgWidth + '/ew ) ELSE (' +
|
||||
svgHeight + '/eh ) END as s ' +
|
||||
', ex0 as x0, ey0 as y0 FROM extent_info ) ' +
|
||||
'SELECT st_TransScale(e, -x0, -y0, s, s)::box2d as ' +
|
||||
gn + '_box, ST_Dimension(' + gn + ') as ' + gn +
|
||||
@ -66,7 +66,7 @@ SvgFormat.prototype.startStreaming = function () {
|
||||
if (this.bbox) {
|
||||
// expand box by "radius" + "stroke-width"
|
||||
// TODO: use a Box2d class for these ops
|
||||
var growby = radius + stroke_width;
|
||||
var growby = radius + strokeWidth;
|
||||
this.bbox.xmin -= growby;
|
||||
this.bbox.ymin -= growby;
|
||||
this.bbox.xmax += growby;
|
||||
@ -76,8 +76,8 @@ SvgFormat.prototype.startStreaming = function () {
|
||||
rootTag += 'viewBox="' + this.bbox.xmin + ' ' + (-this.bbox.ymax) + ' ' +
|
||||
this.bbox.width + ' ' + this.bbox.height + '" ';
|
||||
}
|
||||
rootTag += 'style="fill-opacity:' + fill_opacity + '; stroke:' + stroke_color + '; ' +
|
||||
'stroke-width:' + stroke_width + '; fill:' + fill_color + '" ';
|
||||
rootTag += 'style="fill-opacity:' + fillOpacity + '; stroke:' + strokeColor + '; ' +
|
||||
'stroke-width:' + strokeWidth + '; fill:' + fillColor + '" ';
|
||||
rootTag += 'xmlns="http://www.w3.org/2000/svg" version="1.1">\n';
|
||||
|
||||
header.push(rootTag);
|
||||
@ -87,11 +87,10 @@ SvgFormat.prototype.startStreaming = function () {
|
||||
this._streamingStarted = true;
|
||||
};
|
||||
|
||||
// jshint maxcomplexity:11
|
||||
SvgFormat.prototype.handleQueryRow = function (row) {
|
||||
this.totalRows++;
|
||||
|
||||
if (!row.hasOwnProperty(this.opts.gn)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(row, this.opts.gn)) {
|
||||
this.error = new Error('column "' + this.opts.gn + '" does not exist');
|
||||
}
|
||||
|
||||
@ -100,19 +99,17 @@ SvgFormat.prototype.handleQueryRow = function (row) {
|
||||
return;
|
||||
} // null or empty
|
||||
|
||||
// jshint ignore:start
|
||||
var gdims = row[this.opts.gn + '_dimension'];
|
||||
// TODO: add an identifier, if any of "cartodb_id", "oid", "id", "gid" are found
|
||||
// TODO: add "class" attribute to help with styling ?
|
||||
if (gdims == '0') {
|
||||
if (gdims === 0) {
|
||||
this.buffer += '<circle r="' + radius + '" ' + g + ' />\n';
|
||||
} else if (gdims == '1') {
|
||||
} else if (gdims === 1) {
|
||||
// Avoid filling closed linestrings
|
||||
this.buffer += '<path ' + (fill_color !== 'none' ? 'fill="none" ' : '') + 'd="' + g + '" />\n';
|
||||
} else if (gdims == '2') {
|
||||
this.buffer += '<path ' + (fillColor !== 'none' ? 'fill="none" ' : '') + 'd="' + g + '" />\n';
|
||||
} else if (gdims === 2) {
|
||||
this.buffer += '<path d="' + g + '" />\n';
|
||||
}
|
||||
// jshint ignore:end
|
||||
|
||||
if (!this.bbox) {
|
||||
// Parse layer extent: "BOX(x y, X Y)"
|
||||
|
@ -1,7 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
// jshint ignore:start
|
||||
|
||||
var Pg = require('./../pg');
|
||||
var _ = require('underscore');
|
||||
var geojson = require('./geojson');
|
||||
@ -55,6 +53,7 @@ TopoJsonFormat.prototype.handleQueryEnd = function () {
|
||||
|
||||
var immediately = global.setImmediate || process.nextTick;
|
||||
|
||||
/* eslint-disable */
|
||||
function streamObjectSubtree (obj, key, done) {
|
||||
buffer += '"' + key + '":';
|
||||
|
||||
@ -97,6 +96,7 @@ TopoJsonFormat.prototype.handleQueryEnd = function () {
|
||||
done();
|
||||
}
|
||||
}
|
||||
/* eslint-enable */
|
||||
|
||||
if (jsonpCallback) {
|
||||
buffer += jsonpCallback + '(';
|
||||
@ -136,5 +136,3 @@ TopoJsonFormat.prototype.cancel = function () {
|
||||
};
|
||||
|
||||
module.exports = TopoJsonFormat;
|
||||
|
||||
// jshint ignore:end
|
||||
|
@ -15,7 +15,6 @@ process.env.PGAPPNAME = process.env.PGAPPNAME || 'cartodb_sqlapi';
|
||||
// override Date.toJSON
|
||||
require('./utils/date-to-json');
|
||||
|
||||
// jshint maxcomplexity:9
|
||||
module.exports = function createServer (statsClient) {
|
||||
const options = getServerOptions();
|
||||
const app = express();
|
||||
|
@ -25,7 +25,7 @@ function createTimeoutError () {
|
||||
' Refactor your query before running again or contact CARTO support for more details.',
|
||||
context: 'limit',
|
||||
detail: 'datasource',
|
||||
http_status: 429
|
||||
httpStatus: 429
|
||||
});
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ function createGenericError (err) {
|
||||
context: err.context,
|
||||
detail: err.detail,
|
||||
hint: err.hint,
|
||||
http_status: err.http_status,
|
||||
httpStatus: err.http_status,
|
||||
name: codeToCondition[err.code] || err.name
|
||||
});
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
class ErrorHandler extends Error {
|
||||
constructor ({ message, context, detail, hint, http_status, name }) {
|
||||
constructor ({ message, context, detail, hint, httpStatus, name }) {
|
||||
super(message);
|
||||
|
||||
this.http_status = this.getHttpStatus(http_status);
|
||||
this.http_status = this.getHttpStatus(httpStatus);
|
||||
this.context = context;
|
||||
this.detail = detail;
|
||||
this.hint = hint;
|
||||
@ -23,12 +23,12 @@ class ErrorHandler extends Error {
|
||||
};
|
||||
}
|
||||
|
||||
getHttpStatus (http_status = 400) {
|
||||
getHttpStatus (httpStatus = 400) {
|
||||
if (this.message.includes('permission denied')) {
|
||||
return 403;
|
||||
}
|
||||
|
||||
return http_status;
|
||||
return httpStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,16 +25,16 @@ module.exports = {
|
||||
instance = new StatsD(config);
|
||||
instance.last_error = { msg: '', count: 0 };
|
||||
instance.socket.on('error', function (err) {
|
||||
var last_err = instance.last_error;
|
||||
var last_msg = last_err.msg;
|
||||
var this_msg = '' + err;
|
||||
if (this_msg !== last_msg) {
|
||||
var lastErr = instance.last_error;
|
||||
var lastMsg = lastErr.msg;
|
||||
var thisMsg = '' + err;
|
||||
if (thisMsg !== lastMsg) {
|
||||
debug('statsd client socket error: ' + err);
|
||||
instance.last_error.count = 1;
|
||||
instance.last_error.msg = this_msg;
|
||||
instance.last_error.msg = thisMsg;
|
||||
} else {
|
||||
++last_err.count;
|
||||
if (!last_err.interval) {
|
||||
++lastErr.count;
|
||||
if (!lastErr.interval) {
|
||||
instance.last_error.interval = setInterval(function () {
|
||||
var count = instance.last_error.count;
|
||||
if (count > 1) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
// jshint ignore:start
|
||||
function pad (n) {
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
/* eslint-disable no-extend-native */
|
||||
Date.prototype.toJSON = function () {
|
||||
var s = this.getFullYear() + '-' + pad(this.getMonth() + 1) + '-' + pad(this.getDate()) + 'T' +
|
||||
pad(this.getHours()) + ':' + pad(this.getMinutes()) + ':' + pad(this.getSeconds());
|
||||
@ -16,4 +16,4 @@ Date.prototype.toJSON = function () {
|
||||
}
|
||||
return s;
|
||||
};
|
||||
// jshint ignore:end
|
||||
/* eslint-enable no-extend-native */
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function sanitize_filename (filename) {
|
||||
module.exports = function sanitizeFilename (filename) {
|
||||
filename = path.basename(filename, path.extname(filename));
|
||||
filename = filename.replace(/[;()\[\]<>'"\s]/g, '_');
|
||||
filename = filename.replace(/[;()\[\]<>'"\s]/g, '_'); // eslint-disable-line no-useless-escape
|
||||
return filename;
|
||||
};
|
||||
|
@ -6,14 +6,14 @@ module.exports = {
|
||||
* from object for logs RegEx
|
||||
*
|
||||
* @param {Object} object
|
||||
* @param {Number} max_string_length
|
||||
* @param {Number} maxStringLength
|
||||
*/
|
||||
stringifyForLogs (object, max_string_length = 1024) {
|
||||
return JSON.stringify(cloneAndFilter(object, max_string_length));
|
||||
stringifyForLogs (object, maxStringLength = 1024) {
|
||||
return JSON.stringify(cloneAndFilter(object, maxStringLength));
|
||||
}
|
||||
};
|
||||
|
||||
function cloneAndFilter (object, max_string_length) {
|
||||
function cloneAndFilter (object, maxStringLength) {
|
||||
if (!object || !(object instanceof Object)) {
|
||||
return null;
|
||||
}
|
||||
@ -22,13 +22,13 @@ function cloneAndFilter (object, max_string_length) {
|
||||
|
||||
Object.keys(object).map(key => {
|
||||
if (typeof object[key] === 'string') {
|
||||
newObject[key] = filterString(object[key], max_string_length);
|
||||
newObject[key] = filterString(object[key], maxStringLength);
|
||||
} else if (typeof object[key] === 'object') {
|
||||
newObject[key] = cloneAndFilter(object[key], max_string_length);
|
||||
newObject[key] = cloneAndFilter(object[key], maxStringLength);
|
||||
} else if (object[key] instanceof Array) {
|
||||
newObject[key] = [];
|
||||
for (const element of object[key]) {
|
||||
newObject[key].push(cloneAndFilter(element, max_string_length));
|
||||
newObject[key].push(cloneAndFilter(element, maxStringLength));
|
||||
}
|
||||
} else {
|
||||
newObject[key] = object[key];
|
||||
@ -38,8 +38,8 @@ function cloneAndFilter (object, max_string_length) {
|
||||
return newObject;
|
||||
}
|
||||
|
||||
function filterString (s, max_string_length) {
|
||||
function filterString (s, maxStringLength) {
|
||||
return s
|
||||
.substring(0, max_string_length)
|
||||
.substring(0, maxStringLength)
|
||||
.replace(/[^a-zA-Z0-9]/g, ' ');
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ describe('results-pagination', function () {
|
||||
var authorized = 0;
|
||||
var testing = 0;
|
||||
var method = 0;
|
||||
// jshint maxcomplexity:7
|
||||
var testNext = function () {
|
||||
if (testing >= pr.length) {
|
||||
if (method + 1 >= methods.length) {
|
||||
|
@ -34,7 +34,6 @@ assert.response = function (server, req, res, callback) {
|
||||
|
||||
debug('Request definition', req);
|
||||
|
||||
// jshint maxcomplexity:10
|
||||
function onServerListening () {
|
||||
debug('Server listening on port = %d', port);
|
||||
var status = res.status || res.statusCode;
|
||||
|
@ -32,7 +32,7 @@ describe('error-handler-factory', function () {
|
||||
context: error.context,
|
||||
detail: error.detail,
|
||||
hint: error.hint,
|
||||
http_status: error.http_status,
|
||||
httpStatus: error.http_status,
|
||||
name: codeToCondition[error.code] || error.name
|
||||
});
|
||||
|
||||
@ -48,7 +48,7 @@ describe('error-handler-factory', function () {
|
||||
' Refactor your query before running again or contact CARTO support for more details.',
|
||||
context: 'limit',
|
||||
detail: 'datasource',
|
||||
http_status: 429
|
||||
httpStatus: 429
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(errorHandler, expectedError);
|
||||
@ -62,7 +62,7 @@ describe('error-handler-factory', function () {
|
||||
context: error.context,
|
||||
detail: error.detail,
|
||||
hint: error.hint,
|
||||
http_status: 403,
|
||||
httpStatus: 403,
|
||||
name: codeToCondition[error.code] || error.name
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user