aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/technicaldebt/RemediationCostTimeUnit.java47
-rw-r--r--sonar-core/src/test/java/org/sonar/core/technicaldebt/RemediationCostTimeUnitTest.java26
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb16
4 files changed, 29 insertions, 63 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
index 5f12e68eee0..56028bc0908 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -528,6 +528,9 @@ issue.component_deleted=Removed
issue.changelog.changed_to={0} changed to {1}
issue.changelog.was=was {0}
issue.changelog.removed={0} removed
+issue.remedation_cost.x_days={0} days
+issue.remedation_cost.x_hours={0} hours
+issue.remedation_cost.x_minutes={0} minutes
#------------------------------------------------------------------------------
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/RemediationCostTimeUnit.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/RemediationCostTimeUnit.java
index ae7d50ed9a7..67ae89e0159 100644
--- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/RemediationCostTimeUnit.java
+++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/RemediationCostTimeUnit.java
@@ -19,15 +19,11 @@
*/
package org.sonar.core.technicaldebt;
-import javax.annotation.CheckForNull;
-
-import java.util.concurrent.TimeUnit;
-
public class RemediationCostTimeUnit {
- private TimeUnitValue days;
- private TimeUnitValue hours;
- private TimeUnitValue minutes;
+ private long days;
+ private long hours;
+ private long minutes;
private static final int ONE_HOUR_IN_MINUTE = 60;
@@ -35,58 +31,33 @@ public class RemediationCostTimeUnit {
int oneWorkingDay = hoursInDay * ONE_HOUR_IN_MINUTE;
if (input >= oneWorkingDay) {
long nbDays = input / oneWorkingDay;
- this.days = new TimeUnitValue(nbDays, TimeUnit.DAYS);
+ this.days = nbDays;
input = input - (nbDays * oneWorkingDay);
- } else {
- this.days = new TimeUnitValue(0L, TimeUnit.DAYS);
}
if (input >= ONE_HOUR_IN_MINUTE) {
long nbHours = input / ONE_HOUR_IN_MINUTE;
- this.hours = new TimeUnitValue(nbHours, TimeUnit.HOURS);
+ this.hours = nbHours;
input = input - (nbHours * ONE_HOUR_IN_MINUTE);
- } else {
- this.hours = new TimeUnitValue(0L, TimeUnit.HOURS);
}
- this.minutes = new TimeUnitValue(input, TimeUnit.MINUTES);
+ this.minutes = input;
}
public static RemediationCostTimeUnit of(Long time, int hoursInDay) {
return new RemediationCostTimeUnit(time, hoursInDay);
}
- @CheckForNull
- public TimeUnitValue days() {
+ public long days() {
return days;
}
- @CheckForNull
- public TimeUnitValue hours() {
+ public long hours() {
return hours;
}
- @CheckForNull
- public TimeUnitValue minutes() {
+ public long minutes() {
return minutes;
}
- public static class TimeUnitValue {
-
- private long value;
- private TimeUnit unit;
-
- private TimeUnitValue(long value, TimeUnit unit) {
- this.value = value;
- this.unit = unit;
- }
-
- public long value() {
- return value;
- }
-
- public TimeUnit unit() {
- return unit;
- }
- }
}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/RemediationCostTimeUnitTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/RemediationCostTimeUnitTest.java
index c655b69449c..ab611144e6c 100644
--- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/RemediationCostTimeUnitTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/RemediationCostTimeUnitTest.java
@@ -21,8 +21,6 @@ package org.sonar.core.technicaldebt;
import org.junit.Test;
-import java.util.concurrent.TimeUnit;
-
import static org.fest.assertions.Assertions.assertThat;
public class RemediationCostTimeUnitTest {
@@ -44,27 +42,9 @@ public class RemediationCostTimeUnitTest {
}
private void checkTimes(RemediationCostTimeUnit remediationCostTimeUnit, Long expectedMinutes, Long expectedHours, Long expectedDays ) {
- if (expectedMinutes != null) {
- checkTime(remediationCostTimeUnit.minutes(), expectedMinutes, TimeUnit.MINUTES);
- } else {
- assertThat(remediationCostTimeUnit.minutes().value()).isEqualTo(0L);
- }
- if (expectedHours != null) {
- checkTime(remediationCostTimeUnit.hours(), expectedHours, TimeUnit.HOURS);
- } else {
- assertThat(remediationCostTimeUnit.hours().value()).isEqualTo(0L);
- }
- if (expectedDays != null) {
- checkTime(remediationCostTimeUnit.days(), expectedDays, TimeUnit.DAYS);
- } else {
- assertThat(remediationCostTimeUnit.days().value()).isEqualTo(0L);
- }
- }
-
- private void checkTime(RemediationCostTimeUnit.TimeUnitValue timeUnitValue, Long expectedValue, TimeUnit expectedUnit) {
- assertThat(timeUnitValue.value()).isEqualTo(expectedValue);
- assertThat(timeUnitValue.unit()).isEqualTo(expectedUnit);
+ assertThat(remediationCostTimeUnit.minutes()).isEqualTo(expectedMinutes);
+ assertThat(remediationCostTimeUnit.hours()).isEqualTo(expectedHours);
+ assertThat(remediationCostTimeUnit.days()).isEqualTo(expectedDays);
}
-
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
index 440c3949959..eaaa91a7084 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
@@ -39,8 +39,20 @@
<% if issue.remediationCost %>
<img src="<%= ApplicationController.root_context -%>/images/sep12.png"/>
&nbsp;
- <span><%= issue.remediationCost -%></span>
- &nbsp;
+ <% remediaction_cost_time_unit = Internal.issues.remediationCost(issue)
+ if remediaction_cost_time_unit
+ days = remediaction_cost_time_unit.days
+ hours = remediaction_cost_time_unit.hours
+ minutes = remediaction_cost_time_unit.minutes
+ message = ''
+ message += message('issue.remedation_cost.x_days', :params => days) + ' ' if days > 0
+ message += message('issue.remedation_cost.x_hours', :params => hours) + ' ' if hours > 0
+ # Do not display minutes if days is not null to not have too much information
+ message += message('issue.remedation_cost.x_minutes', :params => minutes) if minutes > 0 && days == 0
+ %>
+ <span><%= message -%></span>
+ &nbsp;
+ <% end %>
<% end %>
</div>