diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2012-12-05 15:51:05 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2012-12-05 15:51:19 +0100 |
commit | eb1cec2773144b6f0d1fffd341747deed90aa062 (patch) | |
tree | a3956ce60716a2dde67597fc18290df28d6badb5 /sonar-batch/src | |
parent | 7d603e52d7e084f93485d50a71227b4c32eff3e8 (diff) | |
download | sonarqube-eb1cec2773144b6f0d1fffd341747deed90aa062.tar.gz sonarqube-eb1cec2773144b6f0d1fffd341747deed90aa062.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-batch/src')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrap/DurationLabel.java | 29 |
1 files changed, 16 insertions, 13 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 28596dd5e03..a8274c50bfc 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 @@ -45,31 +45,34 @@ public class DurationLabel { double nbHours = nbMinutes / 60; double nbDays = nbHours / 24; double nbYears = nbDays / 365; + String message = getMessage(nbSeconds, nbMinutes, nbHours, nbDays, nbYears); + return join(message, suffixAgo); + } - String time = MessageFormat.format(this.years, Math.floor(nbYears)); + private String getMessage(double nbSeconds, double nbMinutes, double nbHours, double nbDays, double nbYears) { + String message = MessageFormat.format(this.years, Math.floor(nbYears)); if (nbSeconds < 45) { - time = this.seconds; + message = this.seconds; } else if (nbSeconds < 90) { - time = this.minute; + message = this.minute; } else if (nbMinutes < 45) { - time = MessageFormat.format(this.minutes, Math.round(nbMinutes)); + message = MessageFormat.format(this.minutes, Math.round(nbMinutes)); } else if (nbMinutes < 90) { - time = this.hour; + message = this.hour; } else if (nbHours < 24) { - time = MessageFormat.format(this.hours, Math.round(nbHours)); + message = MessageFormat.format(this.hours, Math.round(nbHours)); } else if (nbHours < 48) { - time = this.day; + message = this.day; } else if (nbDays < 30) { - time = MessageFormat.format(this.days, Math.floor(nbDays)); + message = MessageFormat.format(this.days, Math.floor(nbDays)); } else if (nbDays < 60) { - time = this.month; + message = this.month; } else if (nbDays < 365) { - time = MessageFormat.format(this.months, Math.floor(nbDays / 30)); + message = MessageFormat.format(this.months, Math.floor(nbDays / 30)); } else if (nbYears < 2) { - time = this.year; + message = this.year; } - - return join(time, suffixAgo); + return message; } @VisibleForTesting |