aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-05-29 09:57:48 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-05-29 09:58:17 +0200
commit38fabc429eb7a73b920f0d55bc0600ae319e71ad (patch)
tree39c77b2181ea734eeb038a5654557885fc864e5d
parent64ebe202328730191176144b2aef966b3bf43b9f (diff)
downloadsonarqube-38fabc429eb7a73b920f0d55bc0600ae319e71ad.tar.gz
sonarqube-38fabc429eb7a73b920f0d55bc0600ae319e71ad.zip
SONAR-3755 fix regression on severity
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java6
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java10
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java4
3 files changed, 14 insertions, 6 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java
index eea97b60d0b..e187b923dd2 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java
@@ -19,18 +19,14 @@
*/
package org.sonar.core.issue;
-import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import org.sonar.api.issue.Issuable;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rule.Severity;
import javax.annotation.Nullable;
-
-import java.util.Date;
import java.util.Map;
import java.util.UUID;
@@ -120,7 +116,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder {
issue.setProjectKey(projectKey);
issue.setRuleKey(ruleKey);
issue.setMessage(message);
- issue.setSeverity(Objects.firstNonNull(severity, Severity.MAJOR));
+ issue.setSeverity(severity);
issue.setManualSeverity(false);
issue.setEffortToFix(effortToFix);
issue.setLine(line);
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java
index e56a212c99c..eb55c784461 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java
@@ -59,4 +59,14 @@ public class DefaultIssueBuilderTest {
assertThat(issue.attribute("YOUTRACK")).isEqualTo("YT-123");
assertThat(issue.attributes()).hasSize(2);
}
+
+ @Test
+ public void should_not_set_default_severity() {
+ DefaultIssue issue = (DefaultIssue) new DefaultIssueBuilder()
+ .componentKey("Action.java")
+ .ruleKey(RuleKey.of("squid", "NullDereference"))
+ .build();
+
+ assertThat(issue.severity()).isNull();
+ }
}
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
index c816a3c4b04..1b4ac5a61b2 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
@@ -20,6 +20,7 @@
package org.sonar.server.issue;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
import com.google.common.base.Strings;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
@@ -28,6 +29,7 @@ import org.sonar.api.issue.ActionPlan;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.IssueComment;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rule.Severity;
import org.sonar.core.issue.ActionPlanStats;
import org.sonar.core.issue.DefaultActionPlan;
import org.sonar.core.issue.DefaultIssue;
@@ -144,7 +146,7 @@ public class InternalRubyIssueService implements ServerComponent {
.componentKey(componentKey)
.line(RubyUtils.toInteger(params.get("line")))
.message(params.get("message"))
- .severity(params.get("severity"))
+ .severity(Objects.firstNonNull(params.get("severity"), Severity.MAJOR))
.effortToFix(RubyUtils.toDouble(params.get("effortToFix")))
.ruleKey(ruleKey)
.reporter(UserSession.get().login())