accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject [accumulo] branch master updated: Fix JavaScript code quality issues (#980)
Date Fri, 22 Feb 2019 18:47:37 GMT
This is an automated email from the ASF dual-hosted git repository.

mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 1fb85d3  Fix JavaScript code quality issues (#980)
1fb85d3 is described below

commit 1fb85d3a18fd82fd6b496c5688105dbe77f16051
Author: Mike Walch <mwalch@apache.org>
AuthorDate: Fri Feb 22 13:47:33 2019 -0500

    Fix JavaScript code quality issues (#980)
    
    * Removed unused variables
    * Use delete only on properties
    * Use === for string comparison
---
 .../apache/accumulo/monitor/resources/js/master.js |  6 ++----
 .../apache/accumulo/monitor/resources/js/navbar.js | 22 +++++++++++-----------
 .../accumulo/monitor/resources/js/overview.js      | 20 ++++++++++----------
 .../apache/accumulo/monitor/resources/js/server.js |  3 +--
 .../accumulo/monitor/resources/js/tservers.js      |  1 -
 .../apache/accumulo/monitor/resources/js/vis.js    |  8 ++------
 6 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/master.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/master.js
index 8a1717f..7f119e4 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/master.js
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/master.js
@@ -65,16 +65,14 @@ function recoveryList() {
   } else {
     $('#recoveryList').show();
 
-    var items = [];
-
     // Creates the table for the recovery list
     $.each(data.recoveryList, function(key, val) {
       var items = [];
       items.push(createFirstCell(val.server, val.server));
       items.push(createRightCell(val.log, val.log));
       var date = new Date(parseInt(val.time));
-      date = date.toLocaleString().split(' ').join('&nbsp;');
-      items.push(createRightCell(val.time, date));
+      var dateStr = date.toLocaleString().split(' ').join('&nbsp;');
+      items.push(createRightCell(val.time, dateStr));
       items.push(createRightCell(val.progress, val.progress));
 
       $('<tr/>', {
diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
index 4a93db2..9582666 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
@@ -47,39 +47,39 @@ function refreshSideBarNotifications() {
       undefined : JSON.parse(sessionStorage.status);
 
   // Setting individual status notification
-  if (data.masterStatus == 'OK') {
+  if (data.masterStatus === 'OK') {
     $('#masterStatusNotification').removeClass('error').addClass('normal');
   } else {
     $('#masterStatusNotification').removeClass('normal').addClass('error');
   }
-  if (data.tServerStatus == 'OK') {
+  if (data.tServerStatus === 'OK') {
     $('#serverStatusNotification').removeClass('error').removeClass('warning').
         addClass('normal');
-  } else if (data.tServerStatus == 'WARN') {
+  } else if (data.tServerStatus === 'WARN') {
     $('#serverStatusNotification').removeClass('error').removeClass('normal').
         addClass('warning');
   } else {
     $('#serverStatusNotification').removeClass('normal').removeClass('warning').
         addClass('error');
   }
-  if (data.gcStatus == 'OK') {
+  if (data.gcStatus === 'OK') {
     $('#gcStatusNotification').removeClass('error').addClass('normal');
   } else {
     $('#gcStatusNotification').addClass('error').removeClass('normal');
   }
 
   // Setting overall status notification
-  if (data.masterStatus == 'OK' &&
-      data.tServerStatus == 'OK' &&
-      data.gcStatus == 'OK') {
+  if (data.masterStatus === 'OK' &&
+      data.tServerStatus === 'OK' &&
+      data.gcStatus === 'OK') {
     $('#statusNotification').removeClass('error').removeClass('warning').
         addClass('normal');
-  } else if (data.masterStatus == 'ERROR' ||
-      data.tServerStatus == 'ERROR' ||
-      data.gcStatus == 'ERROR') {
+  } else if (data.masterStatus === 'ERROR' ||
+      data.tServerStatus === 'ERROR' ||
+      data.gcStatus === 'ERROR') {
     $('#statusNotification').removeClass('normal').removeClass('warning').
         addClass('error');
-  } else if (data.tServerStatus == 'WARN') {
+  } else if (data.tServerStatus === 'WARN') {
     $('#statusNotification').removeClass('normal').removeClass('error').
         addClass('warning');
   }
diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js
index 5f44cf6..e0d0a12 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js
@@ -119,7 +119,7 @@ function refreshZKTable() {
 var plotOptions = {
   colors: ['#d9534f', '#337ab7'],
   grid: {
-    backgroundColor: {colors: ['#fff', '#eee']},
+    backgroundColor: {colors: ['#fff', '#eee']}
   },
   lines: {
     show: true
@@ -166,7 +166,7 @@ function makePlots() {
     {label: 'Read', data: []},
     {label: 'Returned', data: []}
   ];
-  var data = sessionStorage.scanEntries === undefined ?
+  data = sessionStorage.scanEntries === undefined ?
       [] : JSON.parse(sessionStorage.scanEntries);
   $.each(data[0].second, function(key, val) {
     scanEntries[0].data.push([val.first - n, val.second]);
@@ -178,7 +178,7 @@ function makePlots() {
 
   // Create Ingest MB plot
   var ingestMB = [{data:[]}];
-  var data = sessionStorage.ingestMB === undefined ?
+  data = sessionStorage.ingestMB === undefined ?
       [] : JSON.parse(sessionStorage.ingestMB);
   $.each(data, function(key, val) {
     ingestMB[0].data.push([val.first - n, val.second]);
@@ -187,7 +187,7 @@ function makePlots() {
 
   // Create Query MB plot
   var queryMB = [{data:[]}];
-  var data = sessionStorage.queryMB === undefined ?
+  data = sessionStorage.queryMB === undefined ?
       [] : JSON.parse(sessionStorage.queryMB);
   $.each(data, function(key, val) {
     queryMB[0].data.push([val.first - n, val.second]);
@@ -196,7 +196,7 @@ function makePlots() {
 
   // Create Load Average plot
   var loadAvg = [{data:[]}];
-  var data = sessionStorage.loadAvg === undefined ?
+  data = sessionStorage.loadAvg === undefined ?
       [] : JSON.parse(sessionStorage.loadAvg);
   $.each(data, function(key, val) {
     loadAvg[0].data.push([val.first - n, val.second]);
@@ -205,7 +205,7 @@ function makePlots() {
 
   // Create Seeks plot
   var lookups = [{data:[]}];
-  var data = sessionStorage.lookups === undefined ?
+  data = sessionStorage.lookups === undefined ?
       [] : JSON.parse(sessionStorage.lookups);
   $.each(data, function(key, val) {
     lookups[0].data.push([val.first - n, val.second]);
@@ -214,7 +214,7 @@ function makePlots() {
 
   // Create Minor Compactions plot
   var minor = [{data:[]}];
-  var data = sessionStorage.minorCompactions === undefined ?
+  data = sessionStorage.minorCompactions === undefined ?
       [] : JSON.parse(sessionStorage.minorCompactions);
   $.each(data, function(key, val) {
     minor[0].data.push([val.first - n, val.second]);
@@ -223,7 +223,7 @@ function makePlots() {
 
   // Create Major Compaction plot
   var major = [{data:[]}];
-  var data = sessionStorage.majorCompactions === undefined ?
+  data = sessionStorage.majorCompactions === undefined ?
       [] : JSON.parse(sessionStorage.majorCompactions);
   $.each(data, function(key, val) {
     major[0].data.push([val.first - n, val.second]);
@@ -232,7 +232,7 @@ function makePlots() {
 
   // Create Index Cache plot
   var indexCache = [{data:[]}];
-  var data = sessionStorage.indexCache === undefined ?
+  data = sessionStorage.indexCache === undefined ?
       [] : JSON.parse(sessionStorage.indexCache);
   $.each(data, function(key, val) {
     indexCache[0].data.push([val.first - n, val.second]);
@@ -241,7 +241,7 @@ function makePlots() {
 
   // Create Data Cache plot
   var dataCache = [{data:[]}];
-  var data = sessionStorage.dataCache === undefined ?
+  data = sessionStorage.dataCache === undefined ?
       [] : JSON.parse(sessionStorage.dataCache);
   $.each(data, function(key, val) {
     dataCache[0].data.push([val.first - n, val.second]);
diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/server.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/server.js
index bd489b8..c8658df 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/server.js
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/server.js
@@ -21,7 +21,7 @@ var tabletResults;
  * Makes the REST calls, generates the tables with the new information
  */
 function refreshServer() {
-  getTServer(serv).then(function() {;
+  getTServer(serv).then(function() {
     refreshDetailTable();
     refreshHistoryTable();
     refreshCurrentTable();
@@ -96,7 +96,6 @@ function refreshHistoryTable() {
       totalTimeSpent += val.timeSpent;
     });
 
-    var count = 0;
     $.each(data.allTimeTabletResults, function(key, val) {
       var row = [];
 
diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js
index 995b55e..51008c4 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js
@@ -103,7 +103,6 @@ function refreshBadTServersTable() {
     $('#badtservers').hide();
   } else {
     $('#badtservers').show();
-    var items = [];
     $.each(data.badServers, function(key, val) {
       var items = [];
       items.push(createFirstCell(val.id, val.id));
diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/vis.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/vis.js
index bcf5327..78a3d83 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/vis.js
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/vis.js
@@ -71,8 +71,6 @@ function setStats() {
     adjustMax[val.name] = val.adjustMax;
     significance[val.name] = val.significance;
   });
-
-  var numNormalStats = 8;
 }
 
 // size and spacing variables
@@ -169,10 +167,8 @@ function handleNewData() {
   }
 
   initDerivedInfo(newstats);
-  var oldstats = stats;
   while (drawing) {}
   stats = newstats;
-  delete oldstats;
   xmlReturned = true;
 }
 
@@ -184,7 +180,7 @@ function setDerivedStats(serverStats) {
   for (var s in statNames) {
     if (statNames[s])
       continue;
-    normStat = serverStats[s] / maxStatValues[s];
+    var normStat = serverStats[s] / maxStatValues[s];
     if (normStat > 0)
       avgStat += normStat;
     if (maxStat < normStat) {
@@ -461,7 +457,7 @@ function showId(e) {
   var relx = x - canvas.offsetLeft - main.offsetLeft;
   var rely = y - canvas.offsetTop - main.offsetTop;
   var width = Math.ceil(Math.sqrt(stats.servers.length));
-  gotDot = Math.floor(relx / (dotSpacing * 2)) + width *
+  var gotDot = Math.floor(relx / (dotSpacing * 2)) + width *
       Math.floor(rely / (dotSpacing * 2));
   mousedDot = -1;
   if (relx < (width * dotSpacing * 2) && gotDot >= 0 &&


Mime
View raw message