Avoid calling Object.prototype methods directly on object instances

This commit is contained in:
Daniel García Aubert
2019-10-21 23:33:27 +02:00
parent d89e785440
commit 7a1d2ca205
42 changed files with 166 additions and 166 deletions
@@ -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;
+3 -3
View File
@@ -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(',') + ']'
));