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
+1 -1
View File
@@ -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(
+2 -2
View File
@@ -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)
};
}
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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];
}
});
+1 -1
View File
@@ -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()