diff options
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java | 33 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java | 7 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/rule/RuleType.java (renamed from sonar-core/src/main/java/org/sonar/core/issue/IssueType.java) | 14 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/rule/RuleTypeTest.java (renamed from sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java) | 16 |
4 files changed, 35 insertions, 35 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java index 1f623fa01b9..fdb925e2c03 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java @@ -26,20 +26,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.apache.commons.lang.time.DateUtils; -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.api.utils.Duration; -import org.sonar.core.issue.tracking.Trackable; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; @@ -50,13 +36,26 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.commons.lang.time.DateUtils; +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.api.utils.Duration; +import org.sonar.core.issue.tracking.Trackable; +import org.sonar.core.rule.RuleType; import static java.lang.String.format; public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.Issue { private String key; - private IssueType type; + private RuleType type; private String componentUuid; private String componentKey; @@ -127,11 +126,11 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure. return this; } - public IssueType type() { + public RuleType type() { return type; } - public DefaultIssue setType(IssueType type) { + public DefaultIssue setType(RuleType type) { this.type = type; return this; } 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 2607d9384ff..c486c661162 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 @@ -29,6 +29,7 @@ import org.sonar.api.issue.Issuable; import org.sonar.api.issue.Issuable.IssueBuilder; import org.sonar.api.issue.Issue; import org.sonar.api.rule.RuleKey; +import org.sonar.core.rule.RuleType; import org.sonar.core.util.Uuids; public class DefaultIssueBuilder implements Issuable.IssueBuilder { @@ -42,7 +43,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { private Double effortToFix; private String reporter; private String assignee; - private IssueType type; + private RuleType type; private Map<String, String> attributes; public DefaultIssueBuilder() { @@ -124,7 +125,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { return this; } - public DefaultIssueBuilder type(@Nullable IssueType type) { + public DefaultIssueBuilder type(@Nullable RuleType type) { this.type = type; return this; } @@ -147,7 +148,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { DefaultIssue issue = new DefaultIssue(); String key = Uuids.create(); issue.setKey(key); - issue.setType(Objects.firstNonNull(type, IssueType.CODE_SMELL)); + issue.setType(Objects.firstNonNull(type, RuleType.CODE_SMELL)); issue.setComponentKey(componentKey); issue.setProjectKey(projectKey); issue.setRuleKey(ruleKey); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueType.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleType.java index 19c1bf35b42..577c4f73f45 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/IssueType.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleType.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.issue; +package org.sonar.core.rule; import com.google.common.base.Enums; import com.google.common.collect.Lists; @@ -25,12 +25,12 @@ import java.util.List; import static java.lang.String.format; -public enum IssueType { +public enum RuleType { CODE_SMELL(1), BUG(2), VULNERABILITY(3); private final int dbConstant; - IssueType(int dbConstant) { + RuleType(int dbConstant) { this.dbConstant = dbConstant; } @@ -41,15 +41,15 @@ public enum IssueType { /** * Returns the enum constant of the specified DB column value. */ - public static IssueType valueOf(int dbConstant) { + public static RuleType valueOf(int dbConstant) { // iterating the array is fast-enough as size is small. No need for a map. - for (IssueType type : values()) { + for (RuleType type : values()) { if (type.getDbConstant() == dbConstant) { return type; } } - throw new IllegalArgumentException(format("Unsupported value for db column ISSUES.ISSUE_TYPE: %d", dbConstant)); + throw new IllegalArgumentException(format("Unsupported type value : %d", dbConstant)); } - public static final List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(IssueType.class).reverse()); + public static final List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(RuleType.class).reverse()); } diff --git a/sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java b/sonar-core/src/test/java/org/sonar/core/rule/RuleTypeTest.java index a02bc77c728..5035cd9f495 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java +++ b/sonar-core/src/test/java/org/sonar/core/rule/RuleTypeTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.issue; +package org.sonar.core.rule; import org.junit.Rule; import org.junit.Test; @@ -25,32 +25,32 @@ import org.junit.rules.ExpectedException; import static org.assertj.core.api.Assertions.assertThat; -public class IssueTypeTest { +public class RuleTypeTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void test_valueOf_db_constant() { - assertThat(IssueType.valueOf(1)).isEqualTo(IssueType.CODE_SMELL); - assertThat(IssueType.valueOf(2)).isEqualTo(IssueType.BUG); + assertThat(RuleType.valueOf(1)).isEqualTo(RuleType.CODE_SMELL); + assertThat(RuleType.valueOf(2)).isEqualTo(RuleType.BUG); } @Test public void valueOf_throws_ISE_if_unsupported_db_constant() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Unsupported value for db column ISSUES.ISSUE_TYPE: 4"); - IssueType.valueOf(4); + expectedException.expectMessage("Unsupported type value : 4"); + RuleType.valueOf(4); } @Test public void test_ALL_NAMES() { - assertThat(IssueType.ALL_NAMES).containsOnly("BUG", "VULNERABILITY", "CODE_SMELL"); + assertThat(RuleType.ALL_NAMES).containsOnly("BUG", "VULNERABILITY", "CODE_SMELL"); } @Test public void ALL_NAMES_is_immutable() { expectedException.expect(UnsupportedOperationException.class); - IssueType.ALL_NAMES.add("foo"); + RuleType.ALL_NAMES.add("foo"); } } |