From 458642949a14fdabe5c85696f1ee23d50695d07f Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sat, 15 Sep 2018 18:09:47 +0300 Subject: [PATCH] [Minor] Initialize variables at declaration --- .eslintrc.json | 1 - interface/js/app/config.js | 11 ++++------- interface/js/app/history.js | 13 +++++-------- interface/js/app/rspamd.js | 2 +- interface/js/app/stats.js | 2 +- interface/js/app/upload.js | 2 +- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 0d61454ca..b48d887db 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -60,7 +60,6 @@ "function-paren-newline": "off", "global-require": "off", "guard-for-in": "off", - "init-declarations": "off", "key-spacing": "off", "line-comment-position": "off", "max-len": "off", diff --git a/interface/js/app/config.js b/interface/js/app/config.js index 2f87525fa..ee950f023 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -47,7 +47,7 @@ define(["jquery"], var items = []; $.each(data[0].data, function (i, item) { var idx = -1; - var label; + var label = null; if (item.action === "greylist") { label = "Greylist"; idx = 0; @@ -145,12 +145,9 @@ define(["jquery"], var $tbody = $(""); $.each(data, function (i, item) { - var label; - if ((item.editable === false || rspamd.read_only)) { - label = "Read"; - } else { - label = "Read Write"; - } + var label = ((item.editable === false || rspamd.read_only)) + ? "Read" + : "Read Write"; var $tr = $(""); $("" + label + "").appendTo($tr); var $span = $("" + item.uri + "").data("item", item); diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 48f2220fe..16d4b49d2 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -30,7 +30,7 @@ define(["jquery", "footable", "humanize"], var rows_per_page = 25; var ui = {}; - var prevVersion; + var prevVersion = null; var htmlEscapes = { "&": "&", "<": "<", @@ -99,12 +99,9 @@ define(["jquery", "footable", "humanize"], item.action = "
" + item.action + "
"; } - var score_content; - if (item.score < item.required_score) { - score_content = "" + item.score.toFixed(2) + " / " + item.required_score + ""; - } else { - score_content = "" + item.score.toFixed(2) + " / " + item.required_score + ""; - } + var score_content = (item.score < item.required_score) + ? "" + item.score.toFixed(2) + " / " + item.required_score + "" + : "" + item.score.toFixed(2) + " / " + item.required_score + ""; item.score = { options: { @@ -159,7 +156,7 @@ define(["jquery", "footable", "humanize"], preprocess_item(item); Object.keys(item.symbols).map(function (key) { - var str; + var str = null; var sym = item.symbols[key]; if (sym.description) { diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 5ade66ce4..1e41afaaf 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -38,7 +38,7 @@ function ($, D3pie, visibility, NProgress, tab_stat, tab_graph, tab_config, var checked_server = "All SERVERS"; var ui = {}; var timer_id = []; - var selData; // Graph's dataset selector state + var selData = null; // Graph's dataset selector state NProgress.configure({ minimum: 0.01, diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index ea8edfd8a..51e41d788 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -34,7 +34,7 @@ define(["jquery", "d3pie", "humanize"], var hours = seconds % 31536000 % 2628000 % 86400 / 3600 >> 0; var minutes = seconds % 31536000 % 2628000 % 86400 % 3600 / 60 >> 0; /* eslint-enable no-bitwise */ - var out; + var out = null; if (years > 0) { if (months > 0) { out = years + "yr " + months + "mth"; diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js index e542667a6..927501248 100644 --- a/interface/js/app/upload.js +++ b/interface/js/app/upload.js @@ -33,7 +33,7 @@ define(["jquery"], // @upload text function uploadText(rspamd, data, source, headers) { - var url; + var url = null; if (source === "spam") { url = "learnspam"; } else if (source === "ham") { -- 2.39.5