From 8495e6e20400c6a4328a875ac5ea0dc7f8e60e7a Mon Sep 17 00:00:00 2001 From: Ann Priestman Date: Thu, 10 May 2018 08:04:53 -0400 Subject: [PATCH] Codacy fixes --- .../EnterpriseHealthMonitor.java | 23 +++++++++--------- .../healthmonitor/TimingMetricGraphPanel.java | 24 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java b/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java index d0c9b50320..d28ef1b475 100644 --- a/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java +++ b/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java @@ -603,7 +603,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener { * and enable/disable as needed. * @throws HealthMonitorException */ - final synchronized void updateFromGlobalEnabledStatus() throws HealthMonitorException { + synchronized void updateFromGlobalEnabledStatus() throws HealthMonitorException { boolean previouslyEnabled = monitorIsEnabled(); @@ -645,10 +645,8 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener { } boolean currentlyEnabled = getGlobalEnabledStatusFromDB(); - if( currentlyEnabled == previouslyEnabled) { - // Nothing needs to be done - } else { - if(currentlyEnabled == false) { + if( currentlyEnabled != previouslyEnabled) { + if( ! currentlyEnabled ) { isEnabled.set(false); deactivateMonitorLocally(); } else { @@ -845,7 +843,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener { * It will delete all current timing data and replace it with randomly generated values. * If there is more than one node, the second node's times will trend upwards. */ - final void populateDatabaseWithSampleData(int nDays, int nNodes, boolean createVerificationData) throws HealthMonitorException { + void populateDatabaseWithSampleData(int nDays, int nNodes, boolean createVerificationData) throws HealthMonitorException { if(! isEnabled.get()) { throw new HealthMonitorException("Can't populate database - monitor not enabled"); @@ -900,6 +898,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener { break; default: minIndexTimeNanos = baseIndex * 1000 * 1000; + break; } long maxIndexTimeOverMin = minIndexTimeNanos * 3; @@ -1169,12 +1168,12 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener { * All times will be in milliseconds. */ static class DatabaseTimingResult { - private long timestamp; // Time the metric was recorded - private String hostname; // Host that recorded the metric - private long count; // Number of metrics collected - private double average; // Average of the durations collected (milliseconds) - private double max; // Maximum value found (milliseconds) - private double min; // Minimum value found (milliseconds) + private final long timestamp; // Time the metric was recorded + private final String hostname; // Host that recorded the metric + private final long count; // Number of metrics collected + private final double average; // Average of the durations collected (milliseconds) + private final double max; // Maximum value found (milliseconds) + private final double min; // Minimum value found (milliseconds) DatabaseTimingResult(ResultSet resultSet) throws SQLException { this.timestamp = resultSet.getLong("timestamp"); diff --git a/Core/src/org/sleuthkit/autopsy/healthmonitor/TimingMetricGraphPanel.java b/Core/src/org/sleuthkit/autopsy/healthmonitor/TimingMetricGraphPanel.java index 907be0df96..5e94471ff8 100644 --- a/Core/src/org/sleuthkit/autopsy/healthmonitor/TimingMetricGraphPanel.java +++ b/Core/src/org/sleuthkit/autopsy/healthmonitor/TimingMetricGraphPanel.java @@ -48,19 +48,19 @@ class TimingMetricGraphPanel extends JPanel { private final static Logger logger = Logger.getLogger(TimingMetricGraphPanel.class.getName()); - private int padding = 25; - private int labelPadding = 25; - private Color lineColor = new Color(0x12, 0x20, 0xdb, 180); - private Color gridColor = new Color(200, 200, 200, 200); - private Color trendLineColor = new Color(150, 10, 10, 200); + private final int padding = 25; + private final int labelPadding = 25; + private final Color lineColor = new Color(0x12, 0x20, 0xdb, 180); + private final Color gridColor = new Color(200, 200, 200, 200); + private final Color trendLineColor = new Color(150, 10, 10, 200); private static final Stroke GRAPH_STROKE = new BasicStroke(2f); private static final Stroke NARROW_STROKE = new BasicStroke(1f); - private int pointWidth = 4; - private int numberYDivisions = 10; + private final int pointWidth = 4; + private final int numberYDivisions = 10; private List timingResults; - private TimingMetricType timingMetricType; - private String metricName; - private boolean doLineGraph; + private final TimingMetricType timingMetricType; + private final String metricName; + private final boolean doLineGraph; private String yUnitString; private TrendLine trendLine; private final long MILLISECONDS_PER_DAY = 1000 * 60 * 60 * 24; @@ -264,7 +264,7 @@ class TimingMetricGraphPanel extends JPanel { int y0 = getHeight() - ((i * graphHeight) / numberYDivisions + bottomGraphPadding); int y1 = y0; - if (timingResults.size() > 0) { + if ( ! timingResults.isEmpty()) { // Draw the grid line g2.setColor(gridColor); g2.drawLine(leftGraphPadding + 1 + pointWidth, y0, getWidth() - rightGraphPadding, y1); @@ -272,7 +272,7 @@ class TimingMetricGraphPanel extends JPanel { // Create the label g2.setColor(Color.BLACK); double yValue = minValueOnYAxis + ((maxValueOnYAxis - minValueOnYAxis) * ((i * 1.0) / numberYDivisions)); - String yLabel = ((int) (yValue * 100 * yLabelScale)) / 100.0 + ""; + String yLabel = Double.toString(((int) (yValue * 100 * yLabelScale)) / 100.0); FontMetrics fontMetrics = g2.getFontMetrics(); labelWidth = fontMetrics.stringWidth(yLabel); g2.drawString(yLabel, x0 - labelWidth - 5, y0 + (fontMetrics.getHeight() / 2) - 3);