aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2023-04-26 11:03:34 -0500
committersonartech <sonartech@sonarsource.com>2023-04-28 20:02:58 +0000
commit23063324622502be596ce9bb613eaa3d993aca19 (patch)
tree8ffd1fa101accda8b1791954e6e576ef02916b55 /sonar-plugin-api-impl
parent4346b3aee97552c11d0cbe6e1af14175fa3441dc (diff)
downloadsonarqube-23063324622502be596ce9bb613eaa3d993aca19.tar.gz
sonarqube-23063324622502be596ce9bb613eaa3d993aca19.zip
Revert "SONAR-19050 update RuleDto to add characteristics"
This reverts commit 145d97dd8fe78d2d19b569e55ade89c056a98fda.
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java17
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRule.java14
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java5
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java10
4 files changed, 20 insertions, 26 deletions
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java
index d2e606bee1a..42418950a25 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java
@@ -26,8 +26,8 @@ import org.sonar.api.batch.rule.Severity;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.sensor.issue.ExternalIssue;
import org.sonar.api.batch.sensor.issue.NewExternalIssue;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import static java.lang.String.format;
@@ -39,7 +39,6 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
private Long effort;
private Severity severity;
private RuleType type;
- private RuleCharacteristic characteristic;
private String engineId;
private String ruleId;
@@ -101,8 +100,9 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
}
@CheckForNull
- public RuleCharacteristic characteristic() {
- return characteristic;
+ @Override
+ public CodeCharacteristic characteristic() {
+ throw new IllegalStateException("Not implemented yet");
}
@Override
@@ -133,15 +133,14 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
}
@Override
- public DefaultExternalIssue characteristic(RuleCharacteristic characteristic) {
- this.characteristic = characteristic;
+ public DefaultExternalIssue type(RuleType type) {
+ this.type = type;
return this;
}
@Override
- public DefaultExternalIssue type(RuleType type) {
- this.type = type;
- return this;
+ public NewExternalIssue characteristic(CodeCharacteristic characteristic) {
+ throw new IllegalStateException("Not implemented yet");
}
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRule.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRule.java
index aefa37f67e7..52a243b8fca 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRule.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRule.java
@@ -26,7 +26,7 @@ import org.sonar.api.batch.sensor.internal.DefaultStorable;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.sensor.rule.AdHocRule;
import org.sonar.api.batch.sensor.rule.NewAdHocRule;
-import org.sonar.api.rules.RuleCharacteristic;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rules.RuleType;
import static org.apache.commons.lang.StringUtils.isNotBlank;
@@ -35,8 +35,6 @@ import static org.sonar.api.utils.Preconditions.checkState;
public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewAdHocRule {
private Severity severity;
private RuleType type;
-
- private RuleCharacteristic characteristic;
private String name;
private String description;
private String engineId;
@@ -99,8 +97,8 @@ public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewA
@CheckForNull
@Override
- public RuleCharacteristic characteristic() {
- return characteristic;
+ public CodeCharacteristic characteristic() {
+ throw new IllegalStateException("Not implemented yet");
}
@Override
@@ -134,8 +132,8 @@ public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewA
}
@Override
- public DefaultAdHocRule characteristic(RuleCharacteristic characteristic) {
- this.characteristic = characteristic;
- return this;
+ public NewAdHocRule characteristic(CodeCharacteristic characteristic) {
+ throw new IllegalStateException("Not implemented yet");
}
+
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
index 46a9b8e8e46..25cb562857d 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
@@ -31,7 +31,6 @@ import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import static org.assertj.core.api.Assertions.assertThat;
@@ -70,8 +69,7 @@ public class DefaultExternalIssueTest {
.forRule(RuleKey.of("repo", "rule"))
.remediationEffortMinutes(10L)
.type(RuleType.BUG)
- .severity(Severity.BLOCKER)
- .characteristic(RuleCharacteristic.SECURE);
+ .severity(Severity.BLOCKER);
assertThat(issue.primaryLocation().inputComponent()).isEqualTo(inputFile);
assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("external_repo", "rule"));
@@ -81,7 +79,6 @@ public class DefaultExternalIssueTest {
assertThat(issue.remediationEffort()).isEqualTo(10L);
assertThat(issue.type()).isEqualTo(RuleType.BUG);
assertThat(issue.severity()).isEqualTo(Severity.BLOCKER);
- assertThat(issue.characteristic()).isEqualTo(RuleCharacteristic.SECURE);
assertThat(issue.primaryLocation().message()).isEqualTo("Wrong way!");
issue.save();
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java
index 6ba0c8dde7b..945b145fedf 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java
@@ -23,7 +23,6 @@ import org.junit.Test;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.sensor.rule.NewAdHocRule;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import static org.assertj.core.api.Assertions.assertThat;
@@ -43,9 +42,8 @@ public class DefaultAdHocRuleTest {
.name("name")
.description("desc")
.severity(Severity.BLOCKER)
- .type(RuleType.CODE_SMELL)
- .characteristic(RuleCharacteristic.COMPLIANT);
- rule.save();
+ .type(RuleType.CODE_SMELL);
+ rule.save();
assertThat(rule.engineId()).isEqualTo("engine");
assertThat(rule.ruleId()).isEqualTo("ruleId");
@@ -53,10 +51,11 @@ public class DefaultAdHocRuleTest {
assertThat(rule.description()).isEqualTo("desc");
assertThat(rule.severity()).isEqualTo(Severity.BLOCKER);
assertThat(rule.type()).isEqualTo(RuleType.CODE_SMELL);
- assertThat(rule.characteristic()).isEqualTo(RuleCharacteristic.COMPLIANT);
+
verify(storage).store(any(DefaultAdHocRule.class));
}
+
@Test
public void description_is_optional() {
SensorStorage storage = mock(SensorStorage.class);
@@ -119,6 +118,7 @@ public class DefaultAdHocRuleTest {
.hasMessageContaining("Name is mandatory");
}
+
@Test
public void fail_to_store_if_no_severity() {
SensorStorage storage = mock(SensorStorage.class);