aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBelen Pruvost <belen.pruvost@sonarsource.com>2022-07-20 12:40:31 +0200
committersonartech <sonartech@sonarsource.com>2022-07-25 20:03:58 +0000
commitacbd890b2e9e8cd7bd23c562026ba2f54c317af8 (patch)
tree34aa48603b0e36500f4dd8a41e6519ff89559a69
parent21ead7bd96a9dbf01603226090d10e0b7884a241 (diff)
downloadsonarqube-acbd890b2e9e8cd7bd23c562026ba2f54c317af8.tar.gz
sonarqube-acbd890b2e9e8cd7bd23c562026ba2f54c317af8.zip
SONAR-16371 - Use EnumTypes for pull issues and pull taints
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java12
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullActionProtobufObjectGenerator.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullTaintActionProtobufObjectGenerator.java7
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java4
-rw-r--r--sonar-ws/src/main/protobuf/ws-issues.proto8
7 files changed, 13 insertions, 29 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
index 1e063a82b15..7611cff2f3c 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
@@ -87,8 +87,6 @@ public final class IssueDto implements Serializable {
*/
private Long selectedAt;
- private Integer priority;
-
// joins
private String ruleKey;
private String ruleRepo;
@@ -583,16 +581,6 @@ public final class IssueDto implements Serializable {
return this;
}
- @CheckForNull
- public Integer getPriority() {
- return priority;
- }
-
- public IssueDto setPriority(@Nullable Integer priority) {
- this.priority = priority;
- return this;
- }
-
/**
* Should only be used to persist in E/S
* <p/>
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
index 2abc40a7e3f..0e1d3f71dd6 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
@@ -608,7 +608,6 @@
result.ruleUuid as ruleUuid,
result.createdAt as createdAt,
result.status as status,
- result.priority,
result.ruleType as ruleType,
result.ruleRepo as ruleRepo,
result.ruleKey as ruleKey,
@@ -627,7 +626,6 @@
t.ruleUuid as ruleUuid,
t.createdAt as createdAt,
t.status as status,
- t.priority,
t.ruleType as ruleType,
t.ruleRepo as ruleRepo,
t.ruleKey as ruleKey,
@@ -645,7 +643,6 @@
i.rule_uuid as ruleUuid,
i.created_at as createdAt,
i.status as status,
- r.priority,
r.rule_type as ruleType,
r.plugin_name as ruleRepo,
r.plugin_rule_key as ruleKey,
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullActionProtobufObjectGenerator.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullActionProtobufObjectGenerator.java
index 0a0df8afa24..c837bbea867 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullActionProtobufObjectGenerator.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullActionProtobufObjectGenerator.java
@@ -62,9 +62,9 @@ public class PullActionProtobufObjectGenerator implements ProtobufObjectGenerato
issueBuilder.setResolved(issueDto.getStatus().equals(org.sonar.api.issue.Issue.STATUS_RESOLVED));
issueBuilder.setRuleKey(issueDto.getRuleKey().toString());
if (issueDto.isManualSeverity() && issueDto.getSeverity() != null) {
- issueBuilder.setUserSeverity(issueDto.getSeverity());
+ issueBuilder.setUserSeverity(Common.Severity.valueOf(issueDto.getSeverity()));
}
- issueBuilder.setType(Common.RuleType.forNumber(issueDto.getType()).name());
+ issueBuilder.setType(Common.RuleType.forNumber(issueDto.getType()));
issueBuilder.setClosed(false);
issueBuilder.setMainLocation(location);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullTaintActionProtobufObjectGenerator.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullTaintActionProtobufObjectGenerator.java
index bef5de03c82..46136cde772 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullTaintActionProtobufObjectGenerator.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/PullTaintActionProtobufObjectGenerator.java
@@ -32,7 +32,6 @@ import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.protobuf.DbIssues;
-import org.sonar.db.rule.SeverityUtil;
import org.sonar.server.user.UserSession;
import org.sonarqube.ws.Common;
import org.sonarqube.ws.Issues;
@@ -89,10 +88,10 @@ public class PullTaintActionProtobufObjectGenerator implements ProtobufObjectGen
taintBuilder.setCreationDate(issueDto.getCreatedAt());
taintBuilder.setResolved(issueDto.getStatus().equals(org.sonar.api.issue.Issue.STATUS_RESOLVED));
taintBuilder.setRuleKey(issueDto.getRuleKey().toString());
- if (issueDto.getPriority() != null) {
- taintBuilder.setSeverity(SeverityUtil.getSeverityFromOrdinal(issueDto.getPriority()));
+ if (issueDto.getSeverity() != null) {
+ taintBuilder.setSeverity(Common.Severity.valueOf(issueDto.getSeverity()));
}
- taintBuilder.setType(Common.RuleType.forNumber(issueDto.getType()).name());
+ taintBuilder.setType(Common.RuleType.forNumber(issueDto.getType()));
taintBuilder.setClosed(false);
taintBuilder.setMainLocation(locationBuilder.build());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java
index bb19b9ca648..699b06e4f91 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java
@@ -210,11 +210,11 @@ public class PullActionTest {
Issues.IssueLite issueLite = issues.get(0);
assertThat(issueLite.getKey()).isEqualTo(issueDto.getKey());
- assertThat(issueLite.getUserSeverity()).isEqualTo("MINOR");
+ assertThat(issueLite.getUserSeverity()).isEqualTo(Common.Severity.MINOR);
assertThat(issueLite.getCreationDate()).isEqualTo(NOW);
assertThat(issueLite.getResolved()).isTrue();
assertThat(issueLite.getRuleKey()).isEqualTo("java:S1000");
- assertThat(issueLite.getType()).isEqualTo(Common.RuleType.forNumber(issueDto.getType()).name());
+ assertThat(issueLite.getType()).isEqualTo(Common.RuleType.forNumber(issueDto.getType()));
Issues.Location location = issueLite.getMainLocation();
assertThat(location.getMessage()).isEqualTo(issueDto.getMessage());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java
index 647e7a41acd..8cd49e768e9 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java
@@ -236,11 +236,11 @@ public class PullTaintActionTest {
assertThat(taints).hasSize(1);
assertThat(taintLite.getKey()).isEqualTo(issueDto.getKey());
- assertThat(taintLite.getSeverity()).isEqualTo("CRITICAL");
+ assertThat(taintLite.getSeverity()).isEqualTo(Common.Severity.MINOR);
assertThat(taintLite.getCreationDate()).isEqualTo(NOW);
assertThat(taintLite.getResolved()).isFalse();
assertThat(taintLite.getRuleKey()).isEqualTo("javasecurity:S1000");
- assertThat(taintLite.getType()).isEqualTo(Common.RuleType.forNumber(issueDto.getType()).name());
+ assertThat(taintLite.getType()).isEqualTo(Common.RuleType.forNumber(issueDto.getType()));
assertThat(taintLite.getAssignedToSubscribedUser()).isTrue();
Issues.Location location = taintLite.getMainLocation();
diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto
index d5ebfd2fe75..32966a90520 100644
--- a/sonar-ws/src/main/protobuf/ws-issues.proto
+++ b/sonar-ws/src/main/protobuf/ws-issues.proto
@@ -260,8 +260,8 @@ message IssueLite {
optional int64 creationDate = 2;
optional bool resolved = 3;
optional string ruleKey = 4;
- optional string userSeverity = 5;
- optional string type = 6;
+ optional sonarqube.ws.commons.Severity userSeverity = 5;
+ optional sonarqube.ws.commons.RuleType type = 6;
optional Location mainLocation = 7;
optional bool closed = 8;
}
@@ -277,8 +277,8 @@ message TaintVulnerabilityLite {
optional int64 creationDate = 2;
optional bool resolved = 3;
optional string ruleKey = 4;
- optional string severity = 5;
- optional string type = 6;
+ optional sonarqube.ws.commons.Severity severity = 5;
+ optional sonarqube.ws.commons.RuleType type = 6;
optional Location mainLocation = 7;
optional bool closed = 8;
repeated Flow flows = 9;