From 1d7ca20ccc95d325e520291fd2596df9d391536b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 17 Oct 2020 00:47:12 +0200 Subject: [PATCH] Remove a linter error. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Configuration.js | 22 +++++++++------------- src/utils/Utils.js | 4 ++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/utils/Configuration.js b/src/utils/Configuration.js index 5833d7e2..31ab1d6b 100644 --- a/src/utils/Configuration.js +++ b/src/utils/Configuration.js @@ -1,4 +1,5 @@ const fs = require('fs'); +const Utils = require('./Utils'); class Configuration { static configurationFile; @@ -18,12 +19,12 @@ class Configuration { static getAutoReconnectTimeout() { // Read conf - return Configuration.getConfig().hasOwnProperty('autoReconnectTimeout') ? Configuration.getConfig().autoReconnectTimeout : 10; + return Utils.objectHasOwnProperty(Configuration.getConfig(), 'autoReconnectTimeout') ? Configuration.getConfig().autoReconnectTimeout : 10; } static getAutoReconnectMaxRetries() { // Read conf - return Configuration.getConfig().hasOwnProperty('autoReconnectMaxRetries') ? Configuration.getConfig().autoReconnectMaxRetries : -1; + return Utils.objectHasOwnProperty(Configuration.getConfig(), 'autoReconnectMaxRetries') ? Configuration.getConfig().autoReconnectMaxRetries : -1; } static getChargingStationTemplateURLs() { @@ -38,7 +39,7 @@ class Configuration { static getNumberofChargingStation() { // Read conf - return (Configuration.getConfig().numberOfStation ? Configuration.getConfig().numberOfStation : 0); + return Configuration.getConfig().numberOfStation ? Configuration.getConfig().numberOfStation : 0; } static useWorkerPool() { @@ -50,20 +51,15 @@ class Configuration { } static getConsoleLog() { - return (Configuration.getConfig().hasOwnProperty('consoleLog') ? Configuration.getConfig().consoleLog : false); + return Utils.objectHasOwnProperty(Configuration.getConfig(), 'consoleLog') ? Configuration.getConfig().consoleLog : false; } static getLogFile() { - return (Configuration.getConfig().hasOwnProperty('logFile') ? Configuration.getConfig().logFile : 'combined.log'); + return Utils.objectHasOwnProperty(Configuration.getConfig(), 'logFile') ? Configuration.getConfig().logFile : 'combined.log'; } static getErrorFile() { - return (Configuration.getConfig().hasOwnProperty('errorFile') ? Configuration.getConfig().errorFile : 'error.log'); - } - - static getMeterValueSampleInterval() { - // Read conf - return (Configuration.getChargingStationConfiguration().hasOwnProperty('MeterValueSampleInterval') ? Configuration.getChargingStationConfiguration().MeterValueSampleInterval * 1000 : 60000); + return Utils.objectHasOwnProperty(Configuration.getConfig(), 'errorFile') ? Configuration.getConfig().errorFile : 'error.log'; } static getAutomaticTransactionConfiguration() { @@ -81,11 +77,11 @@ class Configuration { } static getChargingStationConfiguration() { - return (Configuration.getChargingStationTemplate().hasOwnProperty('Configuration') ? Configuration.getChargingStationTemplate().Configuration : {}); + return Utils.objectHasOwnProperty(Configuration.getChargingStationTemplate(), 'Configuration') ? Configuration.getChargingStationTemplate().Configuration : {}; } static getChargingStationAuthorizationFile() { - return (Configuration.getChargingStationTemplate().hasOwnProperty('authorizationFile') ? Configuration.getChargingStationTemplate().authorizationFile : ''); + return Utils.objectHasOwnProperty(Configuration.getChargingStationTemplate(), 'authorizationFile') ? Configuration.getChargingStationTemplate().authorizationFile : ''; } static getChargingStationConnectors() { diff --git a/src/utils/Utils.js b/src/utils/Utils.js index e85090d4..b04f0613 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -127,6 +127,10 @@ class Utils { const date = new Date(); return date.toISOString().substr(0, 19) + prefixString; } + + static objectHasOwnProperty(object, property) { + return Object.prototype.hasOwnProperty.call(object, property); + } } module.exports = Utils; -- 2.34.1