aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2023-04-27 13:39:47 -0500
committersonartech <sonartech@sonarsource.com>2023-04-28 20:02:59 +0000
commita691a7378f7266347bcb5e662dbf7765ba864f24 (patch)
tree67cfeb03fd4f7e4577f2dd18deb1ff98b120dfb6 /sonar-plugin-api-impl
parentba73cb4253b74bfc7cd720e96b3ef3e8cec04250 (diff)
downloadsonarqube-a691a7378f7266347bcb5e662dbf7765ba864f24.tar.gz
sonarqube-a691a7378f7266347bcb5e662dbf7765ba864f24.zip
[NO JIRA] Implement plugin api related to characteristics as no ops
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.java5
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRule.java5
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java8
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java8
4 files changed, 12 insertions, 14 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 42418950a25..c12df1015e4 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
@@ -102,7 +102,7 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
@CheckForNull
@Override
public CodeCharacteristic characteristic() {
- throw new IllegalStateException("Not implemented yet");
+ return null;
}
@Override
@@ -140,7 +140,8 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
@Override
public NewExternalIssue characteristic(CodeCharacteristic characteristic) {
- throw new IllegalStateException("Not implemented yet");
+ // no op
+ return this;
}
}
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 52a243b8fca..6ececae895f 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
@@ -98,7 +98,7 @@ public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewA
@CheckForNull
@Override
public CodeCharacteristic characteristic() {
- throw new IllegalStateException("Not implemented yet");
+ return null;
}
@Override
@@ -133,7 +133,8 @@ public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewA
@Override
public NewAdHocRule characteristic(CodeCharacteristic characteristic) {
- throw new IllegalStateException("Not implemented yet");
+ // no op
+ return this;
}
}
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 0a71d62ef34..4b48ec35902 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
@@ -54,7 +54,6 @@ public class DefaultExternalIssueTest {
.setWorkDir(temp.newFolder()));
}
-
private DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.php")
.initMetadata("Foo\nBar\n")
.build();
@@ -166,11 +165,10 @@ public class DefaultExternalIssueTest {
}
@Test
- public void characteristic_shouldThrowIllegalStateException() {
+ public void characteristic_shouldBeNoOp() {
SensorStorage storage = mock(SensorStorage.class);
DefaultExternalIssue issue = new DefaultExternalIssue(project, storage);
- assertThatThrownBy(issue::characteristic).isInstanceOf(IllegalStateException.class);
- assertThatThrownBy(() -> issue.characteristic(CodeCharacteristic.CLEAR)).isInstanceOf(IllegalStateException.class);
+ issue.characteristic(CodeCharacteristic.ROBUST);
+ assertThat(issue.characteristic()).isNull();
}
-
}
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 2e8036cc336..e46406b27e4 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
@@ -56,7 +56,6 @@ public class DefaultAdHocRuleTest {
verify(storage).store(any(DefaultAdHocRule.class));
}
-
@Test
public void description_is_optional() {
SensorStorage storage = mock(SensorStorage.class);
@@ -119,7 +118,6 @@ public class DefaultAdHocRuleTest {
.hasMessageContaining("Name is mandatory");
}
-
@Test
public void fail_to_store_if_no_severity() {
SensorStorage storage = mock(SensorStorage.class);
@@ -151,10 +149,10 @@ public class DefaultAdHocRuleTest {
}
@Test
- public void characteristic_shouldThrowIllegalStateException() {
+ public void characteristic_shouldBeNoOp() {
SensorStorage storage = mock(SensorStorage.class);
DefaultAdHocRule rule = new DefaultAdHocRule(storage);
- assertThatThrownBy(() -> rule.characteristic(CodeCharacteristic.CLEAR)).isInstanceOf(IllegalStateException.class);
- assertThatThrownBy(() -> rule.characteristic()).isInstanceOf(IllegalStateException.class);
+ rule.characteristic(CodeCharacteristic.CLEAR);
+ assertThat(rule.characteristic()).isNull();
}
}