Avoid calling Object.prototype methods directly on object instances
This commit is contained in:
@@ -82,7 +82,7 @@ function prepareResponse () {
|
||||
}, {});
|
||||
|
||||
const analysisCatalog = catalog.map(analysis => {
|
||||
if (analysisIdToTable.hasOwnProperty(analysis.node_id)) {
|
||||
if (Object.prototype.hasOwnProperty.call(analysisIdToTable, analysis.node_id)) {
|
||||
analysis.table = analysisIdToTable[analysis.node_id];
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ function errorMessageWithContext (err) {
|
||||
|
||||
for (var prop in err) {
|
||||
// type & message are properties from Error's prototype and will be skipped
|
||||
if (err.hasOwnProperty(prop) && shouldBeExposed(prop)) {
|
||||
if (Object.prototype.hasOwnProperty.call(err, prop) && shouldBeExposed(prop)) {
|
||||
error[prop] = err[prop];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = function lzma () {
|
||||
const lzmaWorker = new LZMA();
|
||||
|
||||
return function lzmaMiddleware (req, res, next) {
|
||||
if (!req.query.hasOwnProperty('lzma')) {
|
||||
if (!Object.prototype.hasOwnProperty.call(req.query, 'lzma')) {
|
||||
return next();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ function _featureCount (ctx) {
|
||||
}
|
||||
|
||||
function _aggrFeatureCount (ctx) {
|
||||
if (ctx.metaOptions.hasOwnProperty('aggrFeatureCount')) {
|
||||
if (Object.prototype.hasOwnProperty.call(ctx.metaOptions, 'aggrFeatureCount')) {
|
||||
// We expect as zoom level as the value of aggrFeatureCount
|
||||
// TODO: it'd be nice to admit an array of zoom levels to
|
||||
// return metadata for multiple levels.
|
||||
@@ -115,7 +115,7 @@ function mergeColumns (results) {
|
||||
return results.reduce((a, b) => {
|
||||
const c = Object.assign({}, b || {}, a || {});
|
||||
Object.keys(c).forEach(key => {
|
||||
if (b.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(b, key)) {
|
||||
c[key] = Object.assign(c[key], b[key]);
|
||||
}
|
||||
});
|
||||
@@ -186,7 +186,7 @@ function _columnStats (ctx, columns, dimensions) {
|
||||
);
|
||||
if (columns[name].type === 'string') {
|
||||
const topN = ctx.metaOptions.columnStats.topCategories || 1024;
|
||||
const includeNulls = ctx.metaOptions.columnStats.hasOwnProperty('includeNulls')
|
||||
const includeNulls = Object.prototype.hasOwnProperty.call(ctx.metaOptions.columnStats, 'includeNulls')
|
||||
? ctx.metaOptions.columnStats.includeNulls
|
||||
: true;
|
||||
|
||||
|
||||
@@ -110,10 +110,10 @@ TemplateMaps.prototype._checkInvalidTemplate = function (template) {
|
||||
if (!placeholderKey.match(_reValidPlaceholderIdentifier)) {
|
||||
return new Error("Invalid characters in placeholder name '" + placeholderKey + "'");
|
||||
}
|
||||
if (!placeholders[placeholderKey].hasOwnProperty('default')) {
|
||||
if (!Object.prototype.hasOwnProperty.call(placeholders[placeholderKey], 'default')) {
|
||||
return new Error("Missing default for placeholder '" + placeholderKey + "'");
|
||||
}
|
||||
if (!placeholders[placeholderKey].hasOwnProperty('type')) {
|
||||
if (!Object.prototype.hasOwnProperty.call(placeholders[placeholderKey], 'type')) {
|
||||
return new Error("Missing type for placeholder '" + placeholderKey + "'");
|
||||
}
|
||||
}
|
||||
@@ -449,7 +449,7 @@ TemplateMaps.prototype.instance = function (template, params) {
|
||||
var all_params = {};
|
||||
var phold = template.placeholders || {};
|
||||
Object.keys(phold).forEach(function (k) {
|
||||
var val = params.hasOwnProperty(k) ? params[k] : phold[k].default;
|
||||
var val = Object.prototype.hasOwnProperty.call(params, k) ? params[k] : phold[k].default;
|
||||
var type = phold[k].type;
|
||||
// properly escape
|
||||
if (type === 'sql_literal') {
|
||||
|
||||
@@ -68,7 +68,7 @@ PostgresDatasource.prototype.getName = function () {
|
||||
};
|
||||
|
||||
PostgresDatasource.prototype.getRamp = function (column, buckets, method, callback) {
|
||||
if (method && !methodTemplates.hasOwnProperty(method)) {
|
||||
if (method && !Object.prototype.hasOwnProperty.call(methodTemplates, method)) {
|
||||
return callback(new Error(
|
||||
'Invalid method "' + method + '", valid methods: [' + Object.keys(methodTemplates).join(',') + ']'
|
||||
));
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ module.exports = class NamedMapProviderCache {
|
||||
const namedMapProviders = this.providerCache.get(namedMapKey) || {};
|
||||
const providerKey = createProviderKey(config, authToken, params);
|
||||
|
||||
if (namedMapProviders.hasOwnProperty(providerKey)) {
|
||||
if (Object.prototype.hasOwnProperty.call(namedMapProviders, providerKey)) {
|
||||
return callback(null, namedMapProviders[providerKey]);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ module.exports = class Aggregation extends BaseDataview {
|
||||
}
|
||||
|
||||
const requiredOptions = VALID_OPERATIONS[options.aggregation];
|
||||
const missingOptions = requiredOptions.filter(requiredOption => !options.hasOwnProperty(requiredOption));
|
||||
const missingOptions = requiredOptions.filter(requiredOption => !Object.prototype.hasOwnProperty.call(options, requiredOption));
|
||||
|
||||
if (missingOptions.length > 0) {
|
||||
throw new Error(
|
||||
|
||||
@@ -16,8 +16,8 @@ const columnTypeQueryTpl = ctx => `SELECT pg_typeof(${ctx.column})::oid FROM (${
|
||||
|
||||
function getPGTypeName (pgType) {
|
||||
return {
|
||||
float: FLOAT_OIDS.hasOwnProperty(pgType),
|
||||
date: DATE_OIDS.hasOwnProperty(pgType)
|
||||
float: Object.prototype.hasOwnProperty.call(FLOAT_OIDS, pgType),
|
||||
date: Object.prototype.hasOwnProperty.call(DATE_OIDS, pgType)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ module.exports = class Histogram {
|
||||
}
|
||||
|
||||
_isDateHistogram (override = {}) {
|
||||
return (this.options.hasOwnProperty('aggregation') || override.hasOwnProperty('aggregation'));
|
||||
return (Object.prototype.hasOwnProperty.call(this.options, 'aggregation') || override.hasOwnProperty('aggregation'));
|
||||
}
|
||||
|
||||
getResult (psql, override, callback) {
|
||||
|
||||
@@ -62,7 +62,7 @@ module.exports = class BaseHistogram extends BaseDataview {
|
||||
}
|
||||
|
||||
_hasOverridenRange (override) {
|
||||
return override && override.hasOwnProperty('start') && override.hasOwnProperty('end');
|
||||
return override && Object.prototype.hasOwnProperty.call(override, 'start') && Object.prototype.hasOwnProperty.call(override, 'end');
|
||||
}
|
||||
|
||||
_getBinStart (override = {}) {
|
||||
|
||||
@@ -237,7 +237,7 @@ ORDER BY bin ASC;
|
||||
}
|
||||
|
||||
_isValidAggregation (override) {
|
||||
return DATE_AGGREGATIONS.hasOwnProperty(this._getAggregation(override));
|
||||
return Object.prototype.hasOwnProperty.call(DATE_AGGREGATIONS, this._getAggregation(override));
|
||||
}
|
||||
|
||||
_getAutomaticAggregation (psql, callback) {
|
||||
|
||||
@@ -138,7 +138,7 @@ ORDER BY 10;`;
|
||||
}
|
||||
|
||||
_hasOverridenBins (override) {
|
||||
return override && override.hasOwnProperty('bins');
|
||||
return override && Object.prototype.hasOwnProperty.call(override, 'bins');
|
||||
}
|
||||
|
||||
_getSummary (result, override) {
|
||||
@@ -179,7 +179,7 @@ ORDER BY 10;`;
|
||||
_populateBinStart (firstRow, override = {}) {
|
||||
let binStart;
|
||||
|
||||
if (override.hasOwnProperty('start')) {
|
||||
if (Object.prototype.hasOwnProperty.call(override, 'start')) {
|
||||
binStart = this._getBinStart(override);
|
||||
} else {
|
||||
binStart = firstRow.min;
|
||||
|
||||
@@ -7,7 +7,7 @@ var filters = {
|
||||
|
||||
function createFilter (filterDefinition) {
|
||||
var filterType = filterDefinition.type.toLowerCase();
|
||||
if (!filters.hasOwnProperty(filterType)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filters, filterType)) {
|
||||
throw new Error('Unknown filter type: ' + filterType);
|
||||
}
|
||||
return new filters[filterType](filterDefinition.column, filterDefinition.params);
|
||||
@@ -23,7 +23,7 @@ AnalysisFilters.prototype.sql = function (rawSql) {
|
||||
|
||||
return Object.keys(filters)
|
||||
.filter(function (filterName) {
|
||||
return applyFilters.hasOwnProperty(filterName) ? applyFilters[filterName] : true;
|
||||
return Object.prototype.hasOwnProperty.call(applyFilters, filterName) ? applyFilters[filterName] : true;
|
||||
})
|
||||
.map(function (filterName) {
|
||||
var filterDefinition = filters[filterName];
|
||||
|
||||
@@ -45,7 +45,7 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function (user, requestMapConf
|
||||
var dataview = dataviews[dataviewName];
|
||||
if (dataview) {
|
||||
var sourceId = dataview.source.id;
|
||||
if (!bySourceId.hasOwnProperty(sourceId)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(bySourceId, sourceId)) {
|
||||
bySourceId[sourceId] = {};
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ function getDataviewColumns (dataview) {
|
||||
var columns = [];
|
||||
var options = dataview.options;
|
||||
['column', 'aggregationColumn'].forEach(function (opt) {
|
||||
if (options.hasOwnProperty(opt) && !!options[opt]) {
|
||||
if (Object.prototype.hasOwnProperty.call(options, opt) && !!options[opt]) {
|
||||
columns.push(options[opt]);
|
||||
}
|
||||
});
|
||||
@@ -316,7 +316,7 @@ function getDataviewsErrors (dataviews) {
|
||||
|
||||
Object.keys(dataviews).forEach(function (dataviewName) {
|
||||
var dataview = dataviews[dataviewName];
|
||||
if (!dataview.hasOwnProperty('source') || !dataview.source.id) {
|
||||
if (!Object.prototype.hasOwnProperty.call(dataview, 'source') || !dataview.source.id) {
|
||||
errors.push(new Error('Dataview "' + dataviewName + '" is missing `source.id` attribute'));
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ function getMissingDataviewsSourceIds (dataviews, sourceId2Node) {
|
||||
Object.keys(dataviews).forEach(function (dataviewName) {
|
||||
var dataview = dataviews[dataviewName];
|
||||
var dataviewSourceId = getDataviewSourceId(dataview);
|
||||
if (!sourceId2Node.hasOwnProperty(dataviewSourceId)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(sourceId2Node, dataviewSourceId)) {
|
||||
missingDataviewsSourceIds.push(new AnalysisError('Node with `source.id="' + dataviewSourceId + '"`' +
|
||||
' not found in analyses for dataview "' + dataviewName + '"'));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ DataviewsWidgetsMapConfigAdapter.prototype.getMapConfig = function (user, reques
|
||||
|
||||
layersFilters.forEach(function (layerFilters) {
|
||||
Object.keys(layerFilters).forEach(function (filterName) {
|
||||
if (!filters.dataviews.hasOwnProperty(filterName)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filters.dataviews, filterName)) {
|
||||
filters.dataviews[filterName] = layerFilters[filterName];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -80,7 +80,7 @@ ResourceLocator.prototype.urlForTemplate = function (tpl, username, cdnDomain, r
|
||||
if (templated) {
|
||||
return {
|
||||
urlTemplate: tpl({
|
||||
cdn_url: (cdnDomain.hasOwnProperty('urlTemplate') ? cdnDomain.urlTemplate : cdnDomain),
|
||||
cdn_url: (Object.prototype.hasOwnProperty.call(cdnDomain, 'urlTemplate') ? cdnDomain.urlTemplate : cdnDomain),
|
||||
user: username,
|
||||
port: this.environment.port,
|
||||
resource: resource.getPath()
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const ServerInfoController = require('./server-info-controller');
|
||||
const StatsClient = require('./stats/client');
|
||||
|
||||
module.exports = function createServer (serverOptions) {
|
||||
if (!serverOptions.hasOwnProperty('routes')) {
|
||||
if (!Object.prototype.hasOwnProperty.call(serverOptions, 'routes')) {
|
||||
throw new Error('Must initialise server with "routes" as base paths configuration');
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ function wrapDates (originalQuery, fields) {
|
||||
* @param {object} field
|
||||
*/
|
||||
function _isDateType (field) {
|
||||
return DATE_OIDS.hasOwnProperty(field.dataTypeID);
|
||||
return Object.prototype.hasOwnProperty.call(DATE_OIDS, field.dataTypeID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ function overviews_view_for_table (table, overviews_metadata, indent) {
|
||||
|
||||
indent = indent || ' ';
|
||||
for (var z in overviews_metadata) {
|
||||
if (overviews_metadata.hasOwnProperty(z) && z !== 'schema') {
|
||||
if (Object.prototype.hasOwnProperty.call(overviews_metadata, z) && z !== 'schema') {
|
||||
sorted_overviews.push([z, overviews_metadata[z].table]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user