Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CodeClimate ESLint warnings #12546

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions web/gui/dashboard_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ netdataDashboard.menu = {
title: 'Fail2ban',
icon: '<i class="fas fa-shield-alt"></i>',
info: 'Netdata keeps track of the current jail status by reading the Fail2ban log file.'
},
}
};


Expand Down Expand Up @@ -973,7 +973,7 @@ netdataDashboard.submenu = {
},

'filesystem.file_access': {
title: 'file access (eBPF)',
title: 'file access (eBPF)'
},

'apps.file_access': {
Expand Down Expand Up @@ -1056,19 +1056,19 @@ netdataDashboard.submenu = {
},

'services.net': {
title: 'network (eBPF)',
title: 'network (eBPF)'
},

'services.page_cache': {
title: 'pache cache (eBPF)',
title: 'pache cache (eBPF)'
},

'netdata.ebpf': {
title: 'eBPF.plugin',
info: 'eBPF (extended Berkeley Packet Filter) is used to collect metrics from inside Linux kernel giving a zoom inside your <a href="#ebpf_system_process_thread">Process</a>, '+
'<a href="#menu_disk">Hard Disk</a>, <a href="#menu_filesystem">Filesystems</a> (<a href="#menu_filesystem_submenu_file_access">File Access</a>, and ' +
'<a href="#menu_filesystem_submenu_directory_cache__eBPF_">Directory Cache</a>).'
},
}
};

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -2872,7 +2872,7 @@ netdataDashboard.context = {
'net.net': {
heads: [
netdataDashboard.gaugeChart('Received', '12%', 'received'),
netdataDashboard.gaugeChart('Sent', '12%', 'sent'),
netdataDashboard.gaugeChart('Sent', '12%', 'sent')
],
info: netBytesInfo
},
Expand Down Expand Up @@ -6196,7 +6196,7 @@ netdataDashboard.context = {
+ ' data-colors="' + NETDATA.colors[1] + '"'
+ ' data-decimal-digits="2"'
+ ' role="application"></div>';
},
}
]
},
'vernemq.average_scheduler_utilization': {
Expand Down Expand Up @@ -6256,7 +6256,7 @@ netdataDashboard.context = {
+ ' data-colors="' + NETDATA.colors[1] + '"'
+ ' data-decimal-digits="2"'
+ ' role="application"></div>';
},
}
]
},
'pulsar.subscription_msg_rate_redeliver': {
Expand Down Expand Up @@ -6356,7 +6356,7 @@ netdataDashboard.context = {
+ ' data-colors="' + NETDATA.colors[1] + '"'
+ ' data-decimal-digits="2"'
+ ' role="application"></div>';
},
}
]
},
'pulsar.namespace_subscription_msg_rate_redeliver': {
Expand Down Expand Up @@ -6419,8 +6419,8 @@ netdataDashboard.context = {
+ ' data-colors="' + NETDATA.colors[2] + '"'
+ ' data-decimal-digits="2"'
+ ' role="application"></div>';
},
],
}
]
},

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -6618,6 +6618,6 @@ netdataDashboard.context = {

'fail2ban.banned_ips': {
info: '<p>The number of banned IP addresses.</p>'
},
}

};
14 changes: 7 additions & 7 deletions web/gui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ var urlOptions = {
const before = alarmTime + timeMarginMs;
const newHash = document.location.hash.replace(
/;alarm_when=[0-9]*/i,
";after=" + after + ";before=" + before,
";after=" + after + ";before=" + before
);
history.replaceState(null, '', newHash);
location.reload();
Expand Down Expand Up @@ -499,18 +499,18 @@ function toggleAgentItem(e, guid) {
// When you stream metrics from netdata to netdata, the receiving netdata now
// has multiple host databases. It's own, and multiple mirrored. Mirrored databases
// can be accessed with <http://localhost:19999/host/NAME/>
const OLD_DASHBOARD_SUFFIX = "old"
let isOldSuffix = true
const OLD_DASHBOARD_SUFFIX = "old";
let isOldSuffix = true;
try {
const currentScriptMainJs = document.currentScript;
const mainJsSrc = currentScriptMainJs.getAttribute("src")
isOldSuffix = mainJsSrc.startsWith("../main.js")
const mainJsSrc = currentScriptMainJs.getAttribute("src");
isOldSuffix = mainJsSrc.startsWith("../main.js");
} catch {
console.warn("current script not detecting, assuming the dashboard is running with /old suffix")
console.warn("current script not detecting, assuming the dashboard is running with /old suffix");
}

function transformWithOldSuffix(url) {
return isOldSuffix ? `../${url}` : url
return isOldSuffix ? `../${url}` : url;
}

function renderStreamedHosts(options) {
Expand Down
8 changes: 4 additions & 4 deletions web/gui/src/dashboard.js/charting.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ NETDATA.chartLibraries = {
},
options: function (state) {
void(state);
return 'flip' + '%7C' + 'abs';
return 'flip%7Cabs';
},
legend: function (state) {
void(state);
Expand Down Expand Up @@ -128,7 +128,7 @@ NETDATA.chartLibraries = {
},
options: function (state) {
void(state);
return 'null2zero' + '%7C' + 'flip' + '%7C' + 'abs';
return 'null2zero%7Cflip%7Cabs';
},
legend: function (state) {
void(state);
Expand Down Expand Up @@ -276,7 +276,7 @@ NETDATA.chartLibraries = {
},
options: function (state) {
void(state);
return 'objectrows' + '%7C' + 'ms';
return 'objectrows%7Cms';
},
legend: function (state) {
void(state);
Expand Down Expand Up @@ -477,7 +477,7 @@ NETDATA.chartLibraries = {
return false;
},
update: NETDATA.textOnlyUpdate,
xssRegexIgnore: new RegExp('^/api/v1/data\.result$'),
xssRegexIgnore: new RegExp('^/api/v1/data\.result$')
}
};

Expand Down
15 changes: 9 additions & 6 deletions web/gui/src/dashboard.js/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NETDATA.registry = {
MASKED_DATA: "***",

isUsingGlobalRegistry: function() {
return NETDATA.registry.server == "https://registry.my-netdata.io";
return NETDATA.registry.server === "https://registry.my-netdata.io";
},

isRegistryEnabled: function() {
Expand Down Expand Up @@ -87,11 +87,14 @@ NETDATA.registry = {
if (!NETDATA.registry.anonymous_statistics_checked) {
NETDATA.registry.anonymous_statistics_checked=true;
if (data.anonymous_statistics) {
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=false;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-N6CBMJD');
(function(w,d,s,l,i){
w[l]=w[l]||[];
w[l].push({'gtm.start': new Date().getTime(), event:'gtm.js'});
var f=d.getElementsByTagName(s)[0], j=d.createElement(s), dl=l!=='dataLayer'?'&l='+l:'';
j.async=false;
j.src= 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j,f);
}(window, document, 'script', 'dataLayer', 'GTM-N6CBMJD'));
dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid});
}
}
Expand Down
8 changes: 4 additions & 4 deletions web/gui/src/dashboard.js/units-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ NETDATA.unitsConversion = {
return seconds.toString() + '.'
+ NETDATA.zeropad(nanoseconds);
}
},
}
}
},

Expand Down Expand Up @@ -387,7 +387,7 @@ NETDATA.unitsConversion = {
// }
// }
const sunit = this.scalableUnits[units];
for (var x of Object.keys(sunit)) {
for (let x of Object.keys(sunit)) {
let m = sunit[x];
if (m <= max && m > tdivider) {
tunits = x;
Expand Down Expand Up @@ -423,7 +423,7 @@ NETDATA.unitsConversion = {

// find the max divider of all charts
let common_units = t[uuid];
for (var x in t) {
for (let x in t) {
if (t.hasOwnProperty(x) && t[x].divider > common_units.divider) {
common_units = t[x];
}
Expand Down Expand Up @@ -490,7 +490,7 @@ NETDATA.unitsConversion = {
} else if (typeof this.convertibleUnits[units] !== 'undefined') {
// units that can be converted
if (desired_units === 'auto') {
for (var x in this.convertibleUnits[units]) {
for (let x in this.convertibleUnits[units]) {
if (this.convertibleUnits[units].hasOwnProperty(x)) {
if (this.convertibleUnits[units][x].check(max)) {
//console.log('DEBUG: ' + uuid.toString() + ' converting ' + units.toString() + ' to: ' + x.toString());
Expand Down
11 changes: 6 additions & 5 deletions web/gui/src/dashboard.js/xss.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ NETDATA.xss = {
}

switch (typeof(obj)) {
case 'string':
case 'string': {
const ret = this.string(obj);
if (ret !== obj) {
console.log('XSS protection changed string ' + name + ' from "' + obj + '" to "' + ret + '"');
}
return ret;

case 'object':
}
case 'object': {
if (obj === null) {
return obj;
}
Expand Down Expand Up @@ -55,9 +55,10 @@ NETDATA.xss = {
}
}
return obj;

default:
}
default: {
return obj;
}
}
},

Expand Down