@cryptotaxi247 / netdata-1 / commits / 9c9da64f3

Some code quality changes according to codacy

BrainDoctor committed Jul 5, 2017 at 16:56 UTC 9c9da64f30eec4bb7a804369ec781b33487bf67f
1 file changed +28 -28
node.d/fronius.node.js
+28 -28
@@ -11,12 +11,12 @@ var netdata = require('netdata');
11
12 netdata.debug('loaded ' + __filename + ' plugin');
13
14 -const power_grid_id = 'p_grid';
15 -const power_pv_id = 'p_pv';
16 -const power_accu_id = 'p_akku'; // not my typo! Using the ID from the API
17 -const consumption_load_id = 'p_load';
18 -const autonomy_id = 'rel_autonomy';
19 -const consumption_self_id = 'rel_selfconsumption';
14 +const powerGridId = 'p_grid';
15 +const powerPvId = 'p_pv';
16 +const powerAccuId = 'p_akku'; // not my typo! Using the ID from the API
17 +const consumptionLoadId = 'p_load';
18 +const autonomyId = 'rel_autonomy';
19 +const consumptionSelfId = 'rel_selfconsumption';
20
21 var fronius = {
22 name: "Fronius",
@@ -33,7 +33,7 @@ var fronius = {
33 multiplier: 1, // the multiplier
34 divisor: 1, // the divisor
35 hidden: false // is hidden (boolean)
36 - }
36 + };
37 },
38
39 // Gets the site power chart. Will be created if not existing.
@@ -43,9 +43,9 @@ var fronius = {
43 if (fronius.isDefined(chart)) return chart;
44
45 var dim = {};
46 - dim[power_grid_id] = this.createBasicDimension(power_grid_id, "Grid");
47 - dim[power_pv_id] = this.createBasicDimension(power_pv_id, "Photovoltaics");
48 - dim[power_accu_id] = this.createBasicDimension(power_accu_id, "Accumulator");
46 + dim[powerGridId] = this.createBasicDimension(powerGridId, "Grid");
47 + dim[powerPvId] = this.createBasicDimension(powerPvId, "Photovoltaics");
48 + dim[powerAccuId] = this.createBasicDimension(powerAccuId, "Accumulator");
49
50 chart = {
51 id: id, // the unique id of the chart
@@ -71,7 +71,7 @@ var fronius = {
71 var chart = fronius.charts[id];
72 if (fronius.isDefined(chart)) return chart;
73 var dim = {};
74 - dim[consumption_load_id] = this.createBasicDimension(consumption_load_id, "Load");
74 + dim[consumptionLoadId] = this.createBasicDimension(consumptionLoadId, "Load");
75
76 chart = {
77 id: id, // the unique id of the chart
@@ -97,8 +97,8 @@ var fronius = {
97 var chart = fronius.charts[id];
98 if (fronius.isDefined(chart)) return chart;
99 var dim = {};
100 - dim[autonomy_id] = this.createBasicDimension(autonomy_id, "Autonomy");
101 - dim[consumption_self_id] = this.createBasicDimension(consumption_self_id, "Self Consumption");
100 + dim[autonomyId] = this.createBasicDimension(autonomyId, "Autonomy");
101 + dim[consumptionSelfId] = this.createBasicDimension(consumptionSelfId, "Self Consumption");
102
103 chart = {
104 id: id, // the unique id of the chart
@@ -127,10 +127,10 @@ var fronius = {
127
128 var dim = {};
129
130 - var inverter_count = Object.keys(inverters).length;
131 - var inverter = inverters[inverter_count.toString()];
130 + var inverterCount = Object.keys(inverters).length;
131 + var inverter = inverters[inverterCount.toString()];
132 var i = 1;
133 - for (i; i <= inverter_count; i++) {
133 + for (i; i <= inverterCount; i++) {
134 if (fronius.isUndefined(inverter)) {
135 netdata.error("Expected an Inverter with a numerical name! " +
136 "Have a look at your JSON output to verify.");
@@ -166,10 +166,10 @@ var fronius = {
166
167 var dim = {};
168
169 - var inverter_count = Object.keys(inverters).length;
170 - var inverter = inverters[inverter_count.toString()];
169 + var inverterCount = Object.keys(inverters).length;
170 + var inverter = inverters[inverterCount.toString()];
171 var i = 1;
172 - for (i; i <= inverter_count; i++) {
172 + for (i; i <= inverterCount; i++) {
173 if (fronius.isUndefined(inverter)) {
174 netdata.error("Expected an Inverter with a numerical name! " +
175 "Have a look at your JSON output to verify.");
@@ -220,9 +220,9 @@ var fronius = {
220
221 // Site Current Power Chart
222 service.begin(fronius.getSitePowerChart(service, 'fronius_' + service.name + '.power'));
223 - service.set(power_grid_id, Math.round(site.P_Grid));
224 - service.set(power_pv_id, Math.round(site.P_PV));
225 - service.set(power_accu_id, Math.round(site.P_Akku));
223 + service.set(powerGridId, Math.round(site.P_Grid));
224 + service.set(powerPvId, Math.round(site.P_PV));
225 + service.set(powerAccuId, Math.round(site.P_Akku));
226 service.end();
227
228 // Site Consumption Chart
@@ -231,21 +231,21 @@ var fronius = {
231 consumption *= -1;
232
233 service.begin(fronius.getSiteConsumptionChart(service, 'fronius_' + service.name + '.consumption'));
234 - service.set(consumption_load_id, Math.round(consumption));
234 + service.set(consumptionLoadId, Math.round(consumption));
235 service.end();
236
237 // Site Autonomy Chart
238 service.begin(fronius.getSiteAutonomyChart(service, 'fronius_' + service.name + '.autonomy'));
239 - service.set(autonomy_id, Math.round(site.rel_Autonomy));
240 - service.set(consumption_self_id, Math.round(site.rel_SelfConsumption));
239 + service.set(autonomyId, Math.round(site.rel_Autonomy));
240 + service.set(consumptionSelfId, Math.round(site.rel_SelfConsumption));
241 service.end();
242
243 // Inverters
244 var inverters = json.Body.Data.Inverters;
245 - var inverter_count = Object.keys(inverters).length;
246 - if (inverter_count <= 0) return;
245 + var inverterCount = Object.keys(inverters).length;
246 + if (inverterCount <= 0) return;
247 var i = 1;
248 - for (i; i <= inverter_count; i++) {
248 + for (i; i <= inverterCount; i++) {
249 var inverter = inverters[i];
250 if (fronius.isUndefined(inverter)) continue;
251 netdata.debug("Setting values");