From 53df3f4abb20e16ba8439991e01562a677cce75e Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 5 Dec 2012 15:46:51 +0100 Subject: [PATCH] Fix some quality flaws --- .../sonar/batch/bootstrap/DurationLabel.java | 42 +++++++++---------- .../sonar/api/utils/DatabaseSemaphore.java | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DurationLabel.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DurationLabel.java index e04109ead9d..28596dd5e03 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DurationLabel.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DurationLabel.java @@ -40,32 +40,32 @@ public class DurationLabel { private String years = "{0} years"; public String label(long durationInMillis) { - double seconds = durationInMillis / 1000.0; - double minutes = seconds / 60; - double hours = minutes / 60; - double days = hours / 24; - double years = days / 365; - - String time = MessageFormat.format(this.years, Math.floor(years)); - if (seconds < 45) { + double nbSeconds = durationInMillis / 1000.0; + double nbMinutes = nbSeconds / 60; + double nbHours = nbMinutes / 60; + double nbDays = nbHours / 24; + double nbYears = nbDays / 365; + + String time = MessageFormat.format(this.years, Math.floor(nbYears)); + if (nbSeconds < 45) { time = this.seconds; - } else if (seconds < 90) { + } else if (nbSeconds < 90) { time = this.minute; - } else if (minutes < 45) { - time = MessageFormat.format(this.minutes, Math.round(minutes)); - } else if (minutes < 90) { + } else if (nbMinutes < 45) { + time = MessageFormat.format(this.minutes, Math.round(nbMinutes)); + } else if (nbMinutes < 90) { time = this.hour; - } else if (hours < 24) { - time = MessageFormat.format(this.hours, Math.round(hours)); - } else if (hours < 48) { + } else if (nbHours < 24) { + time = MessageFormat.format(this.hours, Math.round(nbHours)); + } else if (nbHours < 48) { time = this.day; - } else if (days < 30) { - time = MessageFormat.format(this.days, Math.floor(days)); - } else if (days < 60) { + } else if (nbDays < 30) { + time = MessageFormat.format(this.days, Math.floor(nbDays)); + } else if (nbDays < 60) { time = this.month; - } else if (days < 365) { - time = MessageFormat.format(this.months, Math.floor(days / 30)); - } else if (years < 2) { + } else if (nbDays < 365) { + time = MessageFormat.format(this.months, Math.floor(nbDays / 30)); + } else if (nbYears < 2) { time = this.year; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DatabaseSemaphore.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DatabaseSemaphore.java index 888647c79cd..93d8ef9075a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DatabaseSemaphore.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DatabaseSemaphore.java @@ -57,7 +57,7 @@ public interface DatabaseSemaphore extends BatchComponent, ServerComponent { */ void release(String name); - static class Lock { + class Lock { private String name; private boolean acquired; -- 2.39.5