aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java12
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java4
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java6
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java12
-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/java/org/sonar/db/rule/RuleDto.java10
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java6
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverter.java14
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java25
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverterTest.java12
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java9
-rw-r--r--server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIteratorFactoryIT.java4
-rw-r--r--server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java7
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueDoc.java8
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleDoc.java8
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java8
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleQuery.java8
-rw-r--r--server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java4
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java30
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java24
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java11
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java10
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java30
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleQueryFactory.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleWsSupport.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/RuleMapperTest.java22
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java8
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java8
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRule.java8
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java7
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java6
34 files changed, 175 insertions, 192 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
index 058a8154414..427cc2c31ca 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
@@ -21,8 +21,8 @@ package org.sonar.xoo.rule;
import javax.annotation.Nullable;
import org.sonar.api.SonarRuntime;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleScope;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RuleDescriptionSection;
import org.sonar.api.server.rule.RuleParamType;
@@ -146,7 +146,7 @@ public class XooRulesDefinition implements RulesDefinition {
NewRule oneBugIssuePerTestLine = repo.createRule(OneBugIssuePerTestLineSensor.RULE_KEY).setName("One Bug Issue Per Test Line")
.setScope(RuleScope.TEST)
- .setType(RuleType.BUG).setCharacteristic(RuleCharacteristic.COMPLIANT);
+ .setType(RuleType.BUG).setCharacteristic(CodeCharacteristic.COMPLIANT);
addAllDescriptionSections(oneBugIssuePerTestLine, "Generate a bug issue on each line of a test file. It requires the metric \"lines\".");
oneBugIssuePerTestLine
@@ -190,7 +190,7 @@ public class XooRulesDefinition implements RulesDefinition {
NewRule hotspotWithRangeAndMultipleLocations = repo.createRule(MultilineHotspotSensor.RULE_KEY)
.setName("Creates hotspots with ranges/multiple locations")
.setType(RuleType.SECURITY_HOTSPOT)
- .setCharacteristic(RuleCharacteristic.PORTABLE);
+ .setCharacteristic(CodeCharacteristic.PORTABLE);
addAllDescriptionSections(hotspotWithRangeAndMultipleLocations, "Hotspot with range and multiple locations");
NewRule issueOnEachFileWithExtUnknown = repo.createRule(OneIssuePerUnknownFileSensor.RULE_KEY).setName("Creates issues on each file with extension 'unknown'");
@@ -204,13 +204,13 @@ public class XooRulesDefinition implements RulesDefinition {
NewRule oneCodeSmellIssuePerLine = repo.createRule(OneCodeSmellIssuePerLineSensor.RULE_KEY).setName("One Code Smell Issue Per Line")
.setType(RuleType.CODE_SMELL)
- .setCharacteristic(RuleCharacteristic.STRUCTURED);
+ .setCharacteristic(CodeCharacteristic.STRUCTURED);
oneCodeSmellIssuePerLine
.setDebtRemediationFunction(oneCodeSmellIssuePerLine.debtRemediationFunctions().linear("9min"));
addAllDescriptionSections(oneCodeSmellIssuePerLine, "Generate a code smell issue on each line of a file. It requires the metric \"lines\".");
NewRule oneVulnerabilityIssuePerModule = repo.createRule(OneVulnerabilityIssuePerModuleSensor.RULE_KEY).setName("One Vulnerability Issue Per Module")
- .setType(RuleType.VULNERABILITY).setCharacteristic(RuleCharacteristic.ROBUST);
+ .setType(RuleType.VULNERABILITY).setCharacteristic(CodeCharacteristic.ROBUST);
addAllDescriptionSections(oneVulnerabilityIssuePerModule, "Generate an issue on each module");
oneVulnerabilityIssuePerModule
@@ -276,7 +276,7 @@ public class XooRulesDefinition implements RulesDefinition {
NewRule hotspotWithSingleContext = repo.createRule(HotspotWithSingleContextSensor.RULE_KEY)
.setName("Find security hotspots, how_to_fix with single context")
.setType(RuleType.SECURITY_HOTSPOT)
- .setCharacteristic(RuleCharacteristic.SECURE)
+ .setCharacteristic(CodeCharacteristic.SECURE)
.setActivatedByDefault(false)
.addDescriptionSection(howToFixSectionWithContext("single_context"));
addDescriptionSectionsWithoutContexts(hotspotWithSingleContext, "Search for Security Hotspots with single context in Xoo files");
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
index d851fb4f26f..ac96be2d050 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
@@ -23,9 +23,9 @@ import org.junit.Before;
import org.junit.Test;
import org.sonar.api.SonarEdition;
import org.sonar.api.SonarQubeSide;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.impl.server.RulesDefinitionContext;
import org.sonar.api.internal.SonarRuntimeImpl;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.Version;
@@ -120,7 +120,7 @@ public class XooRulesDefinitionTest {
public void define_xoo_rule_with_characteristic() {
RulesDefinition.Repository repo = context.repository("xoo");
RulesDefinition.Rule oneCodeSmellIssuePerLine = repo.rule("OneCodeSmellIssuePerLine");
- assertThat(oneCodeSmellIssuePerLine.characteristic()).isEqualTo(RuleCharacteristic.STRUCTURED);
+ assertThat(oneCodeSmellIssuePerLine.characteristic()).isEqualTo(CodeCharacteristic.STRUCTURED);
}
private RulesDefinition.Repository getRepository() {
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java
index 1bcd0b5d3d8..a089f5258fa 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java
@@ -27,8 +27,8 @@ import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.junit.Rule;
import org.junit.Test;
+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 org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
@@ -124,8 +124,8 @@ public class IssueDaoIT {
assertThat(issue.parseLocations()).isNull();
assertThat(issue.isExternal()).isTrue();
assertThat(issue.getRuleType()).isEqualTo(RuleType.CODE_SMELL.getDbConstant());
- assertThat(issue.getRuleCharacteristic()).isEqualTo(RuleCharacteristic.CLEAR);
- assertThat(issue.getEffectiveRuleCharacteristic()).isEqualTo(RuleCharacteristic.CLEAR);
+ assertThat(issue.getRuleCharacteristic()).isEqualTo(CodeCharacteristic.CLEAR);
+ assertThat(issue.getEffectiveRuleCharacteristic()).isEqualTo(CodeCharacteristic.CLEAR);
assertFalse(issue.isQuickFixAvailable());
}
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java
index ec138783b03..b15339f6fb9 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java
@@ -34,10 +34,10 @@ import org.apache.ibatis.exceptions.PersistenceException;
import org.jetbrains.annotations.NotNull;
import org.junit.Rule;
import org.junit.Test;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleQuery;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.debt.DebtRemediationFunction;
@@ -57,7 +57,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.rule.RuleStatus.REMOVED;
-import static org.sonar.api.rules.RuleCharacteristic.CLEAR;
public class RuleDaoIT {
private static final String UNKNOWN_RULE_UUID = "unknown-uuid";
@@ -84,7 +83,6 @@ public class RuleDaoIT {
assertThat(underTest.selectByKey(db.getSession(), ruleDto.getKey())).isNotEmpty();
}
-
@Test
public void selectByUuid() {
RuleDto ruleDto = db.rules().insert();
@@ -458,7 +456,7 @@ public class RuleDaoIT {
.setSystemTags(newHashSet("systag1", "systag2"))
.setSecurityStandards(newHashSet("owaspTop10:a1", "cwe:123"))
.setType(RuleType.BUG)
- .setCharacteristic(RuleCharacteristic.TESTED)
+ .setCharacteristic(CodeCharacteristic.TESTED)
.setScope(Scope.ALL)
.setCreatedAt(1_500_000_000_000L)
.setUpdatedAt(2_000_000_000_000L);
@@ -486,7 +484,7 @@ public class RuleDaoIT {
assertThat(ruleDto.getSecurityStandards()).containsOnly("owaspTop10:a1", "cwe:123");
assertThat(ruleDto.getScope()).isEqualTo(Scope.ALL);
assertThat(ruleDto.getType()).isEqualTo(RuleType.BUG.getDbConstant());
- assertThat(ruleDto.getCharacteristic()).isEqualTo(RuleCharacteristic.TESTED);
+ assertThat(ruleDto.getCharacteristic()).isEqualTo(CodeCharacteristic.TESTED);
assertThat(ruleDto.getCreatedAt()).isEqualTo(1_500_000_000_000L);
assertThat(ruleDto.getUpdatedAt()).isEqualTo(2_000_000_000_000L);
assertThat(ruleDto.getDescriptionFormat()).isEqualTo(RuleDto.Format.MARKDOWN);
@@ -521,7 +519,7 @@ public class RuleDaoIT {
.setSecurityStandards(newHashSet("owaspTop10:a1", "cwe:123"))
.setScope(Scope.ALL)
.setType(RuleType.BUG)
- .setCharacteristic(RuleCharacteristic.PORTABLE)
+ .setCharacteristic(CodeCharacteristic.PORTABLE)
.setUpdatedAt(2_000_000_000_000L);
underTest.update(db.getSession(), ruleToUpdate);
@@ -547,7 +545,7 @@ public class RuleDaoIT {
assertThat(ruleDto.getSecurityStandards()).containsOnly("owaspTop10:a1", "cwe:123");
assertThat(ruleDto.getScope()).isEqualTo(Scope.ALL);
assertThat(ruleDto.getType()).isEqualTo(RuleType.BUG.getDbConstant());
- assertThat(ruleDto.getCharacteristic()).isEqualTo(RuleCharacteristic.PORTABLE);
+ assertThat(ruleDto.getCharacteristic()).isEqualTo(CodeCharacteristic.PORTABLE);
assertThat(ruleDto.getCreatedAt()).isEqualTo(rule.getCreatedAt());
assertThat(ruleDto.getUpdatedAt()).isEqualTo(2_000_000_000_000L);
assertThat(ruleDto.getDescriptionFormat()).isEqualTo(RuleDto.Format.MARKDOWN);
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 62f799723ae..e3c25bcd54c 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
@@ -34,8 +34,8 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
+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 org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
@@ -57,7 +57,7 @@ public final class IssueDto implements Serializable {
private int type;
private int ruleType;
- private RuleCharacteristic ruleCharacteristic;
+ private CodeCharacteristic ruleCharacteristic;
private String kee;
private String componentUuid;
private String projectUuid;
@@ -716,18 +716,18 @@ public final class IssueDto implements Serializable {
}
@CheckForNull
- public RuleCharacteristic getRuleCharacteristic() {
+ public CodeCharacteristic getRuleCharacteristic() {
return ruleCharacteristic;
}
@VisibleForTesting
- IssueDto setRuleCharacteristic(RuleCharacteristic ruleCharacteristic) {
+ IssueDto setRuleCharacteristic(CodeCharacteristic ruleCharacteristic) {
this.ruleCharacteristic = ruleCharacteristic;
return this;
}
@CheckForNull
- public RuleCharacteristic getEffectiveRuleCharacteristic() {
+ public CodeCharacteristic getEffectiveRuleCharacteristic() {
return ruleCharacteristic != null ? ruleCharacteristic : convertToRuleCharacteristic(ruleType);
}
@@ -736,7 +736,7 @@ public final class IssueDto implements Serializable {
}
@VisibleForTesting
- IssueDto setRuleType(int ruleType) {
+ IssueDto setRuleType(int ruleType) {
this.ruleType = ruleType;
return this;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java
index 5a01ffd4ff4..a3f1180e9c0 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java
@@ -31,9 +31,9 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import static com.google.common.base.Preconditions.checkArgument;
@@ -99,7 +99,7 @@ public class RuleDto {
private String systemTagsField = null;
private String securityStandardsField = null;
private int type = 0;
- private RuleCharacteristic characteristic = null;
+ private CodeCharacteristic characteristic = null;
private Scope scope = null;
private RuleKey key = null;
@@ -398,15 +398,15 @@ public class RuleDto {
}
@CheckForNull
- public RuleCharacteristic getCharacteristic() {
+ public CodeCharacteristic getCharacteristic() {
return this.characteristic;
}
- public RuleCharacteristic getEffectiveCharacteristic() {
+ public CodeCharacteristic getEffectiveCharacteristic() {
return characteristic != null ? characteristic : RuleTypeToRuleCharacteristicConverter.convertToRuleCharacteristic(type);
}
- public RuleDto setCharacteristic(@Nullable RuleCharacteristic characteristic) {
+ public RuleDto setCharacteristic(@Nullable CodeCharacteristic characteristic) {
this.characteristic = characteristic;
return this;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java
index 1d66b777748..522b03ef125 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java
@@ -25,9 +25,9 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.CheckForNull;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
public class RuleForIndexingDto {
@@ -54,7 +54,7 @@ public class RuleForIndexingDto {
private long createdAt;
private long updatedAt;
private Set<RuleDescriptionSectionDto> ruleDescriptionSectionsDtos = new HashSet<>();
- private RuleCharacteristic characteristic;
+ private CodeCharacteristic characteristic;
@VisibleForTesting
public RuleForIndexingDto() {
@@ -209,7 +209,7 @@ public class RuleForIndexingDto {
this.type = type;
}
- public RuleCharacteristic getCharacteristic() {
+ public CodeCharacteristic getCharacteristic() {
return characteristic;
}
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverter.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverter.java
index 90349c596ce..38f8b643900 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverter.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverter.java
@@ -19,7 +19,7 @@
*/
package org.sonar.db.rule;
-import org.sonar.api.rules.RuleCharacteristic;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rules.RuleType;
public class RuleTypeToRuleCharacteristicConverter {
@@ -27,18 +27,18 @@ public class RuleTypeToRuleCharacteristicConverter {
private RuleTypeToRuleCharacteristicConverter() {
}
- public static RuleCharacteristic convertToRuleCharacteristic(int ruleType) {
+ public static CodeCharacteristic convertToRuleCharacteristic(int ruleType) {
if (ruleType == 0) {
- return RuleCharacteristic.CLEAR;
+ return CodeCharacteristic.CLEAR;
}
return convertToRuleCharacteristic(RuleType.valueOf(ruleType));
}
- public static RuleCharacteristic convertToRuleCharacteristic(RuleType ruleType) {
+ public static CodeCharacteristic convertToRuleCharacteristic(RuleType ruleType) {
return switch (ruleType) {
- case BUG -> RuleCharacteristic.ROBUST;
- case CODE_SMELL -> RuleCharacteristic.CLEAR;
- case SECURITY_HOTSPOT, VULNERABILITY -> RuleCharacteristic.SECURE;
+ case BUG -> CodeCharacteristic.ROBUST;
+ case CODE_SMELL -> CodeCharacteristic.CLEAR;
+ case SECURITY_HOTSPOT, VULNERABILITY -> CodeCharacteristic.SECURE;
};
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java
index 7366e54998e..b8d95de4d58 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java
@@ -27,9 +27,9 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.lang.time.DateUtils;
import org.junit.Test;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
@@ -240,13 +240,13 @@ public class IssueDtoTest {
@Test
public void getEffectiveCharacteristic_when_characteristicInitialized_should_return_characteristicDbConstantValue() {
- IssueDto issueDto = new IssueDto().setRuleType(RuleType.CODE_SMELL.getDbConstant()).setRuleCharacteristic(RuleCharacteristic.CLEAR);
- assertThat(issueDto.getEffectiveRuleCharacteristic()).isEqualTo(RuleCharacteristic.CLEAR);
+ IssueDto issueDto = new IssueDto().setRuleType(RuleType.CODE_SMELL.getDbConstant()).setRuleCharacteristic(CodeCharacteristic.CLEAR);
+ assertThat(issueDto.getEffectiveRuleCharacteristic()).isEqualTo(CodeCharacteristic.CLEAR);
}
@Test
public void getEffectiveCharacteristic_when_characteristicNotInitialized_should_return_characteristicDbConstantValue() {
IssueDto issueDto = new IssueDto().setRuleType(RuleType.CODE_SMELL.getDbConstant());
- assertThat(issueDto.getEffectiveRuleCharacteristic()).isEqualTo(RuleCharacteristic.CLEAR);
+ assertThat(issueDto.getEffectiveRuleCharacteristic()).isEqualTo(CodeCharacteristic.CLEAR);
}
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java
index fc701c189ae..e8483c24d5b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java
@@ -20,17 +20,12 @@
package org.sonar.db.rule;
import com.google.common.collect.ImmutableSet;
-import com.tngtech.java.junit.dataprovider.DataProvider;
-import com.tngtech.java.junit.dataprovider.DataProviderRunner;
-import com.tngtech.java.junit.dataprovider.UseDataProvider;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
import org.jetbrains.annotations.NotNull;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.sonar.api.rules.RuleCharacteristic;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.core.util.Uuids;
@@ -190,31 +185,31 @@ public class RuleDtoTest {
public void getEffectiveCharacteristic_when_noCharacteristicInitialized_should_return_dbConstantValueFromConverter() {
RuleDto rule = new RuleDto().setType(RuleType.BUG);
- RuleCharacteristic characteristic = rule.getCharacteristic();
+ CodeCharacteristic characteristic = rule.getCharacteristic();
assertThat(characteristic).isNull();
- RuleCharacteristic effectiveCharacteristic = rule.getEffectiveCharacteristic();
- RuleCharacteristic expected = RuleTypeToRuleCharacteristicConverter.convertToRuleCharacteristic(RuleType.BUG);
+ CodeCharacteristic effectiveCharacteristic = rule.getEffectiveCharacteristic();
+ CodeCharacteristic expected = RuleTypeToRuleCharacteristicConverter.convertToRuleCharacteristic(RuleType.BUG);
assertThat(effectiveCharacteristic).isEqualTo(expected);
}
@Test
public void getEffectiveCharacteristic_when_characteristicInitialized_should_return_characteristicDbConstantValue() {
- RuleDto rule = new RuleDto().setType(RuleType.BUG).setCharacteristic(RuleCharacteristic.COMPLIANT);
+ RuleDto rule = new RuleDto().setType(RuleType.BUG).setCharacteristic(CodeCharacteristic.COMPLIANT);
- RuleCharacteristic effectiveCharacteristic = rule.getEffectiveCharacteristic();
- RuleCharacteristic characteristic = rule.getCharacteristic();
+ CodeCharacteristic effectiveCharacteristic = rule.getEffectiveCharacteristic();
+ CodeCharacteristic characteristic = rule.getCharacteristic();
- assertThat(effectiveCharacteristic).isEqualTo(characteristic).isEqualTo(RuleCharacteristic.COMPLIANT);
+ assertThat(effectiveCharacteristic).isEqualTo(characteristic).isEqualTo(CodeCharacteristic.COMPLIANT);
}
@Test
public void getEffectiveCharacteristic_whenType0_shouldReturnClearCharacteristic() {
RuleDto rule = new RuleDto().setType(0);
- RuleCharacteristic effectiveCharacteristic = rule.getEffectiveCharacteristic();
+ CodeCharacteristic effectiveCharacteristic = rule.getEffectiveCharacteristic();
- assertThat(effectiveCharacteristic).isEqualTo(RuleCharacteristic.CLEAR);
+ assertThat(effectiveCharacteristic).isEqualTo(CodeCharacteristic.CLEAR);
}
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverterTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverterTest.java
index 8bf53ac0984..508b40744b4 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverterTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTypeToRuleCharacteristicConverterTest.java
@@ -24,7 +24,7 @@ import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.sonar.api.rules.RuleCharacteristic;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rules.RuleType;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,17 +36,17 @@ public class RuleTypeToRuleCharacteristicConverterTest {
@Test
@UseDataProvider("ruleTypeToRulCharacteristicData")
public void convertToRuleCharacteristic_when_receivedNonNullRuleType_should_convertToCorrespondingDefaultCharacteristic(RuleType type,
- RuleCharacteristic expectedCharacteristic) {
+ CodeCharacteristic expectedCharacteristic) {
assertThat(convertToRuleCharacteristic(type)).isEqualTo(expectedCharacteristic);
}
@DataProvider
public static Object[][] ruleTypeToRulCharacteristicData() {
return new Object[][] {
- {RuleType.CODE_SMELL, RuleCharacteristic.CLEAR},
- {RuleType.BUG, RuleCharacteristic.ROBUST},
- {RuleType.VULNERABILITY, RuleCharacteristic.SECURE},
- {RuleType.SECURITY_HOTSPOT, RuleCharacteristic.SECURE}
+ {RuleType.CODE_SMELL, CodeCharacteristic.CLEAR},
+ {RuleType.BUG, CodeCharacteristic.ROBUST},
+ {RuleType.VULNERABILITY, CodeCharacteristic.SECURE},
+ {RuleType.SECURITY_HOTSPOT, CodeCharacteristic.SECURE}
};
}
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
index 07524e2c744..31879e8ba83 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
@@ -23,10 +23,10 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import javax.annotation.Nullable;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RuleParamType;
import org.sonar.core.util.UuidFactory;
@@ -62,10 +62,10 @@ public class RuleTesting {
// only static helpers
}
-
public static RuleDto newRule() {
return newRule(RuleKey.of(randomAlphanumeric(30), randomAlphanumeric(30)));
}
+
public static RuleDto newRule(RuleDescriptionSectionDto... ruleDescriptionSectionDtos) {
return newRule(randomRuleKey(), ruleDescriptionSectionDtos);
}
@@ -93,7 +93,7 @@ public class RuleTesting {
.setName("name_" + randomAlphanumeric(5))
.setDescriptionFormat(RuleDto.Format.HTML)
.setType(CODE_SMELL)
- .setCharacteristic(RuleCharacteristic.CLEAR)
+ .setCharacteristic(CodeCharacteristic.CLEAR)
.setStatus(RuleStatus.READY)
.setConfigKey("configKey_" + ruleKey.rule())
.setSeverity(Severity.ALL.get(nextInt(Severity.ALL.size())))
@@ -151,7 +151,6 @@ public class RuleTesting {
return newRule(XOO_X2).setLanguage("xoo");
}
-
public static RuleDto newTemplateRule(RuleKey ruleKey) {
return newRule(ruleKey)
.setIsTemplate(true);
@@ -214,7 +213,7 @@ public class RuleTesting {
return rule -> rule.setType(type);
}
- public static Consumer<RuleDto> setCharacteristic(RuleCharacteristic characteristic) {
+ public static Consumer<RuleDto> setCharacteristic(CodeCharacteristic characteristic) {
return rule -> rule.setCharacteristic(characteristic);
}
diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIteratorFactoryIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIteratorFactoryIT.java
index cc243f2428e..b39391ba298 100644
--- a/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIteratorFactoryIT.java
+++ b/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIteratorFactoryIT.java
@@ -27,7 +27,7 @@ import java.util.function.Function;
import java.util.stream.Stream;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.rules.RuleCharacteristic;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
@@ -91,7 +91,7 @@ public class IssueIteratorFactoryIT {
assertThat(issue.getTags()).containsOnly("tag1", "tag2", "tag3");
assertThat(issue.effort().toMinutes()).isPositive();
assertThat(issue.type().getDbConstant()).isEqualTo(2);
- assertThat(issue.characteristic()).isEqualTo(RuleCharacteristic.CLEAR);
+ assertThat(issue.characteristic()).isEqualTo(CodeCharacteristic.CLEAR);
}
@Test
diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java
index 9e1f34bff98..819a173657f 100644
--- a/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java
+++ b/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java
@@ -29,6 +29,7 @@ import java.util.Set;
import java.util.function.Consumer;
import org.junit.Rule;
import org.junit.Test;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
@@ -55,14 +56,14 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.entry;
import static org.junit.Assert.fail;
+import static org.sonar.api.code.CodeCharacteristic.CLEAR;
+import static org.sonar.api.code.CodeCharacteristic.COMPLIANT;
+import static org.sonar.api.code.CodeCharacteristic.SECURE;
import static org.sonar.api.rule.Severity.BLOCKER;
import static org.sonar.api.rule.Severity.CRITICAL;
import static org.sonar.api.rule.Severity.INFO;
import static org.sonar.api.rule.Severity.MAJOR;
import static org.sonar.api.rule.Severity.MINOR;
-import static org.sonar.api.rules.RuleCharacteristic.CLEAR;
-import static org.sonar.api.rules.RuleCharacteristic.COMPLIANT;
-import static org.sonar.api.rules.RuleCharacteristic.SECURE;
import static org.sonar.api.rules.RuleType.BUG;
import static org.sonar.api.rules.RuleType.CODE_SMELL;
import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueDoc.java
index abcef42ccc6..20866ba6283 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueDoc.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueDoc.java
@@ -25,8 +25,8 @@ import java.util.Date;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.server.es.BaseDoc;
@@ -134,8 +134,8 @@ public class IssueDoc extends BaseDoc {
return RuleType.valueOf(getField(IssueIndexDefinition.FIELD_ISSUE_TYPE));
}
- public RuleCharacteristic characteristic() {
- return RuleCharacteristic.valueOf(getField(IssueIndexDefinition.FIELD_ISSUE_CHARACTERISTIC));
+ public CodeCharacteristic characteristic() {
+ return CodeCharacteristic.valueOf(getField(IssueIndexDefinition.FIELD_ISSUE_CHARACTERISTIC));
}
@CheckForNull
@@ -271,7 +271,7 @@ public class IssueDoc extends BaseDoc {
return this;
}
- public IssueDoc setCharacteristic(RuleCharacteristic characteristic) {
+ public IssueDoc setCharacteristic(CodeCharacteristic characteristic) {
setField(IssueIndexDefinition.FIELD_ISSUE_CHARACTERISTIC, characteristic.toString());
return this;
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleDoc.java
index b1971790005..a55ddac51f3 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleDoc.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleDoc.java
@@ -30,9 +30,9 @@ import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.db.rule.RuleDescriptionSectionDto;
import org.sonar.db.rule.RuleDto;
@@ -273,13 +273,13 @@ public class RuleDoc extends BaseDoc {
return this;
}
- private RuleDoc setCharacteristic(RuleCharacteristic characteristic) {
+ private RuleDoc setCharacteristic(CodeCharacteristic characteristic) {
setField(RuleIndexDefinition.FIELD_RULE_CHARACTERISTIC, characteristic.name());
return this;
}
- public RuleCharacteristic characteristic() {
- return RuleCharacteristic.valueOf(getField(RuleIndexDefinition.FIELD_RULE_CHARACTERISTIC));
+ public CodeCharacteristic characteristic() {
+ return CodeCharacteristic.valueOf(getField(RuleIndexDefinition.FIELD_RULE_CHARACTERISTIC));
}
public long createdAt() {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
index d3b99c11514..1677902a4ac 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
@@ -50,9 +50,9 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.System2;
import org.sonar.core.util.stream.MoreCollectors;
@@ -298,9 +298,9 @@ public class RuleIndex {
QueryBuilders.termsQuery(FIELD_RULE_TYPE, typeNames));
}
- Collection<RuleCharacteristic> characteristics = query.getCharacteristics();
+ Collection<CodeCharacteristic> characteristics = query.getCharacteristics();
if (isNotEmpty(characteristics)) {
- List<String> characteristicNames = characteristics.stream().map(RuleCharacteristic::name).toList();
+ List<String> characteristicNames = characteristics.stream().map(CodeCharacteristic::name).toList();
filters.put(FIELD_RULE_CHARACTERISTIC,
QueryBuilders.termsQuery(FIELD_RULE_CHARACTERISTIC, characteristicNames));
}
@@ -469,7 +469,7 @@ public class RuleIndex {
(types == null) ? (new String[0]) : types.toArray()));
}
if (options.getFacets().contains(FACET_CHARACTERISTICS)) {
- Collection<RuleCharacteristic> characteristics = query.getCharacteristics();
+ Collection<CodeCharacteristic> characteristics = query.getCharacteristics();
aggregations.put(FACET_CHARACTERISTICS,
stickyFacetBuilder.buildStickyFacet(FIELD_RULE_CHARACTERISTIC, FACET_CHARACTERISTICS,
(characteristics == null) ? (new String[0]) : characteristics.toArray()));
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleQuery.java b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleQuery.java
index 48e5e8b297f..3a90f1b6ba2 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleQuery.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleQuery.java
@@ -23,9 +23,9 @@ import com.google.common.base.Preconditions;
import java.util.Collection;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.db.qualityprofile.QProfileDto;
@@ -41,7 +41,7 @@ public class RuleQuery {
private Collection<RuleStatus> statuses;
private Collection<String> tags;
private Collection<RuleType> types;
- private Collection<RuleCharacteristic> characteristics;
+ private Collection<CodeCharacteristic> characteristics;
private Boolean activation;
private QProfileDto profile;
private QProfileDto compareToQProfile;
@@ -177,11 +177,11 @@ public class RuleQuery {
}
@CheckForNull
- public Collection<RuleCharacteristic> getCharacteristics() {
+ public Collection<CodeCharacteristic> getCharacteristics() {
return characteristics;
}
- public RuleQuery setCharacteristics(@Nullable Collection<RuleCharacteristic> characteristics) {
+ public RuleQuery setCharacteristics(@Nullable Collection<CodeCharacteristic> characteristics) {
this.characteristics = characteristics;
return this;
}
diff --git a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
index 5c1a155175b..7d4708b1d1a 100644
--- a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
+++ b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
@@ -23,9 +23,9 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.HashMap;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.resources.Scopes;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.core.util.Uuids;
import org.sonar.db.component.ComponentDto;
@@ -75,7 +75,7 @@ public class IssueDocTesting {
doc.setKey(Uuids.createFast());
doc.setRuleUuid(Uuids.createFast());
doc.setType(RuleType.CODE_SMELL);
- doc.setCharacteristic(RuleCharacteristic.COMPLIANT);
+ doc.setCharacteristic(CodeCharacteristic.COMPLIANT);
doc.setAssigneeUuid("assignee_uuid_" + randomAlphabetic(26));
doc.setAuthorLogin("author_" + randomAlphabetic(5));
doc.setScope(IssueScope.MAIN);
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
index 6cf042a4273..f18d5619d0a 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
@@ -39,11 +39,11 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.Startable;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleScope;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.server.rule.RulesDefinition;
@@ -209,7 +209,7 @@ public class RegisterRules implements Startable {
RuleDto rule = dbRulesByRuleUuid.get(ruleUuid);
if (rule == null) {
LOG.warn("Could not retrieve rule with uuid %s referenced by a deprecated rule key. " +
- "The following deprecated rule keys seem to be referencing a non-existing rule",
+ "The following deprecated rule keys seem to be referencing a non-existing rule",
ruleUuid, entry.getValue());
} else {
entry.getValue().forEach(d -> rulesByKey.put(d.getOldRuleKeyAsRuleKey(), rule));
@@ -268,10 +268,10 @@ public class RegisterRules implements Startable {
private Stream<RuleDto> getAllModified() {
return Stream.of(
- created.stream(),
- updated.stream(),
- removed.stream(),
- renamed.keySet().stream())
+ created.stream(),
+ updated.stream(),
+ removed.stream(),
+ renamed.keySet().stream())
.flatMap(s -> s);
}
@@ -492,7 +492,7 @@ public class RegisterRules implements Startable {
dto.setType(type);
changed = true;
}
- RuleCharacteristic characteristic = def.characteristic();
+ CodeCharacteristic characteristic = def.characteristic();
if (!Objects.equals(dto.getCharacteristic(), characteristic)) {
dto.setCharacteristic(characteristic);
changed = true;
@@ -670,9 +670,9 @@ public class RegisterRules implements Startable {
changed = true;
} else if (dto.getSystemTags().size() != ruleDef.tags().size() ||
!dto.getSystemTags().containsAll(ruleDef.tags())) {
- dto.setSystemTags(ruleDef.tags());
- changed = true;
- }
+ dto.setSystemTags(ruleDef.tags());
+ changed = true;
+ }
return changed;
}
@@ -684,9 +684,9 @@ public class RegisterRules implements Startable {
changed = true;
} else if (dto.getSecurityStandards().size() != ruleDef.securityStandards().size() ||
!dto.getSecurityStandards().containsAll(ruleDef.securityStandards())) {
- dto.setSecurityStandards(ruleDef.securityStandards());
- changed = true;
- }
+ dto.setSecurityStandards(ruleDef.securityStandards());
+ changed = true;
+ }
return changed;
}
@@ -818,8 +818,8 @@ public class RegisterRules implements Startable {
private static Set<String> getExistingAndRenamedRepositories(RegisterRulesContext recorder, Collection<RulesDefinition.Repository> context) {
return Stream.concat(
- context.stream().map(RulesDefinition.ExtendedRepository::key),
- recorder.getRenamed().map(Map.Entry::getValue).map(RuleKey::repository))
+ context.stream().map(RulesDefinition.ExtendedRepository::key),
+ recorder.getRenamed().map(Map.Entry::getValue).map(RuleKey::repository))
.collect(toSet());
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
index ff98036da12..8ce51cdd4de 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
@@ -36,20 +36,20 @@ import org.jetbrains.annotations.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.impl.utils.TestSystem2;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleScope;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.server.rule.Context;
import org.sonar.api.server.rule.RuleDescriptionSection;
import org.sonar.api.server.rule.RulesDefinition;
-import org.sonar.api.utils.DateUtils;
import org.sonar.api.testfixtures.log.LogTester;
+import org.sonar.api.utils.DateUtils;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.DbClient;
@@ -210,7 +210,7 @@ public class RegisterRulesTest {
assertThat(hotspotRule.getCreatedAt()).isEqualTo(RegisterRulesTest.DATE1.getTime());
assertThat(hotspotRule.getUpdatedAt()).isEqualTo(RegisterRulesTest.DATE1.getTime());
assertThat(hotspotRule.getType()).isEqualTo(RuleType.SECURITY_HOTSPOT.getDbConstant());
- assertThat(hotspotRule.getCharacteristic()).isEqualTo(RuleCharacteristic.SECURE);
+ assertThat(hotspotRule.getCharacteristic()).isEqualTo(CodeCharacteristic.SECURE);
assertThat(hotspotRule.getSecurityStandards()).containsExactly("cwe:1", "cwe:123", "cwe:863", "owaspTop10-2021:a1", "owaspTop10-2021:a3");
}
@@ -237,7 +237,7 @@ public class RegisterRulesTest {
private void verifyExternalRule(RuleDto rule) {
verifyCommonsFields(rule);
- assertThat(rule.getCharacteristic()).isEqualTo(RuleCharacteristic.COMPLIANT);
+ assertThat(rule.getCharacteristic()).isEqualTo(CodeCharacteristic.COMPLIANT);
}
private void verifyCommonsFields(RuleDto rule) {
@@ -422,7 +422,7 @@ public class RegisterRulesTest {
assertThat(rule1.getNoteUserUuid()).isEqualTo("marius");
assertThat(rule1.getStatus()).isEqualTo(READY);
assertThat(rule1.getType()).isEqualTo(RuleType.BUG.getDbConstant());
- assertThat(rule1.getCharacteristic()).isEqualTo(RuleCharacteristic.PORTABLE);
+ assertThat(rule1.getCharacteristic()).isEqualTo(CodeCharacteristic.PORTABLE);
assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime());
assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2.getTime());
assertThat(rule1.getEducationPrinciples()).containsOnly("concept1", "concept4");
@@ -1170,7 +1170,7 @@ public class RegisterRulesTest {
.setInternalKey("config1")
.setTags("tag1", "tag2", "tag3")
.setType(RuleType.CODE_SMELL)
- .setCharacteristic(RuleCharacteristic.ROBUST)
+ .setCharacteristic(CodeCharacteristic.ROBUST)
.setStatus(RuleStatus.BETA);
}
@@ -1182,7 +1182,7 @@ public class RegisterRulesTest {
.setHtmlDescription("Description of One")
.setSeverity(BLOCKER)
.setType(RuleType.CODE_SMELL)
- .setCharacteristic(RuleCharacteristic.TESTED)
+ .setCharacteristic(CodeCharacteristic.TESTED)
.setStatus(RuleStatus.BETA);
Arrays.stream(consumers).forEach(c -> c.accept(newRule));
@@ -1220,7 +1220,7 @@ public class RegisterRulesTest {
.setTags("tag1", "tag2", "tag3")
.setScope(RuleScope.ALL)
.setType(RuleType.CODE_SMELL)
- .setCharacteristic(RuleCharacteristic.CLEAR)
+ .setCharacteristic(CodeCharacteristic.CLEAR)
.setStatus(RuleStatus.BETA)
.setGapDescription("java.S115.effortToFix")
.addEducationPrincipleKeys("concept1", "concept2", "concept3");
@@ -1233,7 +1233,7 @@ public class RegisterRulesTest {
.setName("Hotspot")
.setHtmlDescription("Minimal hotspot")
.setType(RuleType.SECURITY_HOTSPOT)
- .setCharacteristic(RuleCharacteristic.SECURE)
+ .setCharacteristic(CodeCharacteristic.SECURE)
.addOwaspTop10(Y2021, OwaspTop10.A1, OwaspTop10.A3)
.addCwe(1, 123, 863);
@@ -1261,7 +1261,7 @@ public class RegisterRulesTest {
// tag2 and tag3 removed, tag4 added
.setTags("tag1", "tag4")
.setType(RuleType.BUG)
- .setCharacteristic(RuleCharacteristic.PORTABLE)
+ .setCharacteristic(CodeCharacteristic.PORTABLE)
.setStatus(READY)
.setGapDescription("java.S115.effortToFix.v2")
.addEducationPrincipleKeys("concept1", "concept4");
@@ -1303,7 +1303,7 @@ public class RegisterRulesTest {
.setTags("tag1", "tag2", "tag3")
.setScope(RuleScope.ALL)
.setType(RuleType.CODE_SMELL)
- .setCharacteristic(RuleCharacteristic.COMPLIANT)
+ .setCharacteristic(CodeCharacteristic.COMPLIANT)
.setStatus(RuleStatus.BETA)
.addEducationPrincipleKeys("concept1", "concept2", "concept3");
@@ -1311,7 +1311,7 @@ public class RegisterRulesTest {
.setName("Hotspot")
.setHtmlDescription("Minimal hotspot")
.setType(RuleType.SECURITY_HOTSPOT)
- .setCharacteristic(RuleCharacteristic.SECURE)
+ .setCharacteristic(CodeCharacteristic.SECURE)
.addOwaspTop10(Y2021, OwaspTop10.A1, OwaspTop10.A3)
.addCwe(1, 123, 863);
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
index b9c055fa309..59e714acd23 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
@@ -64,9 +64,9 @@ import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.joda.time.Duration;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinition.OwaspTop10Version;
@@ -118,6 +118,7 @@ import static org.sonar.server.es.searchrequest.TopAggregationHelper.NO_OTHER_SU
import static org.sonar.server.issue.index.IssueIndex.Facet.ASSIGNED_TO_ME;
import static org.sonar.server.issue.index.IssueIndex.Facet.ASSIGNEES;
import static org.sonar.server.issue.index.IssueIndex.Facet.AUTHOR;
+import static org.sonar.server.issue.index.IssueIndex.Facet.CHARACTERISTICS;
import static org.sonar.server.issue.index.IssueIndex.Facet.CREATED_AT;
import static org.sonar.server.issue.index.IssueIndex.Facet.CWE;
import static org.sonar.server.issue.index.IssueIndex.Facet.DIRECTORIES;
@@ -138,7 +139,6 @@ import static org.sonar.server.issue.index.IssueIndex.Facet.SONARSOURCE_SECURITY
import static org.sonar.server.issue.index.IssueIndex.Facet.STATUSES;
import static org.sonar.server.issue.index.IssueIndex.Facet.TAGS;
import static org.sonar.server.issue.index.IssueIndex.Facet.TYPES;
-import static org.sonar.server.issue.index.IssueIndex.Facet.CHARACTERISTICS;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE_UUID;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_BRANCH_UUID;
@@ -245,7 +245,7 @@ public class IssueIndex {
// Resolutions facet returns one more element than the number of resolutions to take into account unresolved issues
RESOLUTIONS(PARAM_RESOLUTIONS, FIELD_ISSUE_RESOLUTION, STICKY, Issue.RESOLUTIONS.size() + 1),
TYPES(PARAM_TYPES, FIELD_ISSUE_TYPE, STICKY, RuleType.values().length),
- CHARACTERISTICS(PARAM_CHARACTERISTICS, FIELD_ISSUE_CHARACTERISTIC, STICKY, RuleCharacteristic.values().length),
+ CHARACTERISTICS(PARAM_CHARACTERISTICS, FIELD_ISSUE_CHARACTERISTIC, STICKY, CodeCharacteristic.values().length),
SCOPES(PARAM_SCOPES, FIELD_ISSUE_SCOPE, STICKY, MAX_FACET_SIZE),
LANGUAGES(PARAM_LANGUAGES, FIELD_ISSUE_LANGUAGE, STICKY, MAX_FACET_SIZE),
RULES(PARAM_RULES, FIELD_ISSUE_RULE_UUID, STICKY, MAX_FACET_SIZE),
@@ -492,7 +492,6 @@ public class IssueIndex {
}
}
-
private static Set<String> calculateRequirementsForOwaspAsvs40Params(IssueQuery query) {
int level = query.getOwaspAsvsLevel().orElse(3);
List<String> levelRequirements = OWASP_ASVS_40_REQUIREMENTS_BY_LEVEL.get(level);
@@ -521,10 +520,8 @@ public class IssueIndex {
/**
* <p>Builds the Elasticsearch boolean query to filter the PCI DSS categories.</p>
- *
* <p>The PCI DSS security report handles all the subcategories as one level. This means that subcategory 1.1 doesn't include the issues from 1.1.1.
* Taking this into account, the search filter follows the same logic and uses prefix matching for top-level categories and exact matching for subcategories</p>
- *
* <p>Example</p>
* <p>List of PCI DSS categories in issues: {1.5.8, 1.5.9, 1.6.7}
* <ul>
@@ -985,7 +982,7 @@ public class IssueIndex {
t ->
// add sub-aggregation to return issue count for current user
aggregationHelper.getSubAggregationHelper()
- .buildSelectedItemsAggregation(ASSIGNED_TO_ME.getName(), ASSIGNED_TO_ME.getTopAggregationDef(), new String[]{uuid})
+ .buildSelectedItemsAggregation(ASSIGNED_TO_ME.getName(), ASSIGNED_TO_ME.getTopAggregationDef(), new String[] {uuid})
.ifPresent(t::subAggregation));
esRequest.aggregation(aggregation);
}
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java
index b756c0e3cbd..219c87abaef 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java
@@ -35,10 +35,10 @@ import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.Durations;
@@ -95,8 +95,8 @@ import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
import static org.sonar.api.issue.Issue.STATUS_OPEN;
import static org.sonar.api.issue.Issue.STATUS_RESOLVED;
import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE;
-import static org.sonar.api.rules.RuleType.*;
import static org.sonar.api.rules.RuleType.CODE_SMELL;
+import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
import static org.sonar.api.server.ws.WebService.Param.FACETS;
import static org.sonar.api.utils.DateUtils.formatDateTime;
import static org.sonar.api.utils.DateUtils.parseDate;
@@ -519,8 +519,8 @@ public class SearchActionIT {
@Test
public void search_by_characteristic_when_characteristic_set() {
- RuleDto rule1 = newIssueRule(XOO_X1, r -> r.setCharacteristic(RuleCharacteristic.PORTABLE));
- RuleDto rule2 = newIssueRule(XOO_X2, r -> r.setCharacteristic(RuleCharacteristic.TESTED));
+ RuleDto rule1 = newIssueRule(XOO_X1, r -> r.setCharacteristic(CodeCharacteristic.PORTABLE));
+ RuleDto rule2 = newIssueRule(XOO_X2, r -> r.setCharacteristic(CodeCharacteristic.TESTED));
ComponentDto project = db.components().insertPublicProject("PROJECT_ID", c -> c.setKey("PROJECT_KEY").setLanguage("java"));
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("java"));
@@ -534,7 +534,7 @@ public class SearchActionIT {
indexPermissions();
SearchWsResponse searchWsResponse = ws.newRequest()
- .setParam(PARAM_CHARACTERISTICS, RuleCharacteristic.PORTABLE.name() + "," + RuleCharacteristic.TESTED.name())
+ .setParam(PARAM_CHARACTERISTICS, CodeCharacteristic.PORTABLE.name() + "," + CodeCharacteristic.TESTED.name())
.executeProtobuf(SearchWsResponse.class);
List<Issue> issuesList = searchWsResponse.getIssuesList();
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
index 9b8c6a27327..41a3f301336 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
@@ -29,11 +29,11 @@ import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Test;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.server.ws.WebService;
@@ -403,12 +403,12 @@ public class SearchActionIT {
@Test
public void characteristics_shouldFilterOnCharacteristics() {
- RuleDto rule1 = db.rules().insert(r -> r.setCharacteristic(RuleCharacteristic.ROBUST));
- RuleDto rule2 = db.rules().insert(r -> r.setCharacteristic(RuleCharacteristic.COMPLIANT));
+ RuleDto rule1 = db.rules().insert(r -> r.setCharacteristic(CodeCharacteristic.ROBUST));
+ RuleDto rule2 = db.rules().insert(r -> r.setCharacteristic(CodeCharacteristic.COMPLIANT));
indexRules();
Consumer<TestRequest> populator = r -> r
- .setParam(PARAM_CHARACTERISTICS, RuleCharacteristic.ROBUST.name());
+ .setParam(PARAM_CHARACTERISTICS, CodeCharacteristic.ROBUST.name());
TestRequest request = ws.newRequest();
populator.accept(request);
@@ -419,12 +419,11 @@ public class SearchActionIT {
assertThat(rulesList.get(0).getKey()).isEqualTo(rule1.getKey().toString());
}
-
@Test
public void characteristics_shouldGroupCharacteristicsInTheFacets() {
- RuleDto rule1 = db.rules().insert(r -> r.setCharacteristic(RuleCharacteristic.ROBUST));
- RuleDto rule2 = db.rules().insert(r -> r.setCharacteristic(RuleCharacteristic.COMPLIANT));
- RuleDto rule3 = db.rules().insert(r -> r.setCharacteristic(RuleCharacteristic.COMPLIANT));
+ RuleDto rule1 = db.rules().insert(r -> r.setCharacteristic(CodeCharacteristic.ROBUST));
+ RuleDto rule2 = db.rules().insert(r -> r.setCharacteristic(CodeCharacteristic.COMPLIANT));
+ RuleDto rule3 = db.rules().insert(r -> r.setCharacteristic(CodeCharacteristic.COMPLIANT));
indexRules();
SearchResponse result = ws.newRequest()
@@ -434,15 +433,15 @@ public class SearchActionIT {
Common.Facet facets = result.getFacets().getFacets(0);
int valuesCount = facets.getValuesCount();
- assertThat(valuesCount).isEqualTo(RuleCharacteristic.values().length);
+ assertThat(valuesCount).isEqualTo(CodeCharacteristic.values().length);
List<Common.FacetValue> valuesList = facets.getValuesList();
Common.FacetValue compliantFacetValue = valuesList.get(0);
- assertThat(compliantFacetValue.getVal()).isEqualTo(RuleCharacteristic.COMPLIANT.name());
+ assertThat(compliantFacetValue.getVal()).isEqualTo(CodeCharacteristic.COMPLIANT.name());
assertThat(compliantFacetValue.getCount()).isEqualTo(2);
Common.FacetValue robustFacetValue = valuesList.get(1);
- assertThat(robustFacetValue.getVal()).isEqualTo(RuleCharacteristic.ROBUST.name());
+ assertThat(robustFacetValue.getVal()).isEqualTo(CodeCharacteristic.ROBUST.name());
assertThat(robustFacetValue.getCount()).isEqualTo(1);
}
@@ -1029,10 +1028,10 @@ public class SearchActionIT {
indexRules();
ws.newRequest()
- .setParam(WebService.Param.PAGE, "2")
- .setParam(WebService.Param.PAGE_SIZE, "9")
- .execute()
- .assertJson(this.getClass(), "paging.json");
+ .setParam(WebService.Param.PAGE, "2")
+ .setParam(WebService.Param.PAGE_SIZE, "9")
+ .execute()
+ .assertJson(this.getClass(), "paging.json");
}
@Test
@@ -1084,7 +1083,6 @@ public class SearchActionIT {
assertThat(actualSections).hasSameElementsAs(expected);
}
-
private void verifyNoResults(Consumer<TestRequest> requestPopulator) {
verify(requestPopulator);
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index bd4bc6ab469..6d19ee80964 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -32,8 +32,8 @@ import javax.annotation.Nullable;
import org.apache.lucene.search.TotalHits;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
@@ -283,12 +283,12 @@ public class SearchAction implements IssuesWsAction {
action.createParam(PARAM_CHARACTERISTICS)
.setDescription("Comma-separated list of characteristics.")
.setSince("10.1")
- .setPossibleValues(Arrays.stream(RuleCharacteristic.values()).map(Enum::name).toList())
- .setExampleValue(format(COMMA_SEPERATED_PARAMS_FORMAT, RuleCharacteristic.CLEAR, RuleCharacteristic.COMPLIANT));
+ .setPossibleValues(Arrays.stream(CodeCharacteristic.values()).map(Enum::name).toList())
+ .setExampleValue(format(COMMA_SEPERATED_PARAMS_FORMAT, CodeCharacteristic.CLEAR, CodeCharacteristic.COMPLIANT));
action.createParam(PARAM_OWASP_ASVS_LEVEL)
.setDescription("Level of OWASP ASVS categories.")
.setSince("9.7")
- .setPossibleValues(1,2,3);
+ .setPossibleValues(1, 2, 3);
action.createParam(PARAM_PCI_DSS_32)
.setDescription("Comma-separated list of PCI DSS v3.2 categories.")
.setSince("9.6")
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleQueryFactory.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleQueryFactory.java
index 6b00fd00a30..09c9a67c742 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleQueryFactory.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleQueryFactory.java
@@ -21,8 +21,8 @@ package org.sonar.server.rule.ws;
import java.util.Date;
import java.util.List;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ServerSide;
import org.sonar.api.server.ws.Request;
@@ -67,7 +67,7 @@ public class RuleQueryFactory {
/**
* Similar to {@link #createRuleQuery(DbSession, Request)} but sets additional fields which are only used
- * for the rule search WS.
+ * for the rule search WS.
*/
public RuleQuery createRuleSearchQuery(DbSession dbSession, Request request) {
RuleQuery query = createRuleQuery(dbSession, request);
@@ -100,7 +100,7 @@ public class RuleQueryFactory {
query.setIsTemplate(request.paramAsBoolean(PARAM_IS_TEMPLATE));
query.setTemplateKey(request.param(PARAM_TEMPLATE_KEY));
query.setTypes(toEnums(request.paramAsStrings(PARAM_TYPES), RuleType.class));
- query.setCharacteristics(toEnums(request.paramAsStrings(PARAM_CHARACTERISTICS), RuleCharacteristic.class));
+ query.setCharacteristics(toEnums(request.paramAsStrings(PARAM_CHARACTERISTICS), CodeCharacteristic.class));
query.setKey(request.param(PARAM_RULE_KEY));
query.setCwe(request.paramAsStrings(PARAM_CWE));
query.setOwaspTop10(request.paramAsStrings(PARAM_OWASP_TOP_10));
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleWsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleWsSupport.java
index e1e7874ddb1..b0460af9149 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleWsSupport.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleWsSupport.java
@@ -24,9 +24,9 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ServerSide;
import org.sonar.api.server.ws.WebService;
@@ -177,8 +177,8 @@ public class RuleWsSupport {
.createParam(PARAM_CHARACTERISTICS)
.setSince("10.1")
.setDescription("Comma-separated list of characteristics. Returned rules match any of the characteristics (OR operator)")
- .setPossibleValues(RuleCharacteristic.values())
- .setExampleValue(RuleCharacteristic.CLEAR);
+ .setPossibleValues(CodeCharacteristic.values())
+ .setExampleValue(CodeCharacteristic.CLEAR);
action
.createParam(PARAM_ACTIVATION)
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java
index d9ea1155b47..48fdac1ee23 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java
@@ -38,8 +38,8 @@ import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
@@ -103,7 +103,7 @@ public class SearchAction implements RulesWsAction {
public static final String ACTION = "search";
private static final Collection<String> DEFAULT_FACETS = Set.of(PARAM_LANGUAGES, PARAM_REPOSITORIES, "tags");
- private static final String[] POSSIBLE_FACETS = new String[]{
+ private static final String[] POSSIBLE_FACETS = new String[] {
FACET_LANGUAGES,
FACET_REPOSITORIES,
FACET_TAGS,
@@ -325,7 +325,7 @@ public class SearchAction implements RulesWsAction {
addMandatoryFacetValues(results, FACET_ACTIVE_SEVERITIES, Severity.ALL);
addMandatoryFacetValues(results, FACET_TAGS, request.getTags());
addMandatoryFacetValues(results, FACET_TYPES, RuleType.names());
- addMandatoryFacetValues(results, FACET_CHARACTERISTICS, Arrays.stream(RuleCharacteristic.values()).map(Enum::name).toList());
+ addMandatoryFacetValues(results, FACET_CHARACTERISTICS, Arrays.stream(CodeCharacteristic.values()).map(Enum::name).toList());
addMandatoryFacetValues(results, FACET_CWE, request.getCwe());
addMandatoryFacetValues(results, FACET_OWASP_TOP_10, request.getOwaspTop10());
addMandatoryFacetValues(results, FACET_OWASP_TOP_10_2021, request.getOwaspTop10For2021());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/RuleMapperTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/RuleMapperTest.java
index 022914b12c2..19ea3fcbbac 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/RuleMapperTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/RuleMapperTest.java
@@ -22,15 +22,13 @@ package org.sonar.server.rule.ws;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
-import java.util.List;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.RuleCharacteristic;
import org.sonar.db.rule.RuleDto;
-import org.sonar.server.platform.db.migration.version.DatabaseVersion;
import org.sonarqube.ws.Common;
import org.sonarqube.ws.Rules;
@@ -42,7 +40,7 @@ public class RuleMapperTest {
@Test
@UseDataProvider("pluginApiEnumsMappedToProtobufEnums")
- public void toWsRule_shouldMapCharacteristicEnumToProtobuf(RuleCharacteristic pluginApiEnum, Common.RuleCharacteristic protoEnum) {
+ public void toWsRule_shouldMapCharacteristicEnumToProtobuf(CodeCharacteristic pluginApiEnum, Common.RuleCharacteristic protoEnum) {
RuleMapper ruleMapper = new RuleMapper(mock(Languages.class), mock(), mock());
RuleDto ruleDto = new RuleDto();
@@ -57,14 +55,14 @@ public class RuleMapperTest {
@DataProvider
public static Object[][] pluginApiEnumsMappedToProtobufEnums() {
return new Object[][] {
- {RuleCharacteristic.CLEAR, Common.RuleCharacteristic.CLEAR},
- {RuleCharacteristic.TESTED, Common.RuleCharacteristic.TESTED},
- {RuleCharacteristic.ROBUST, Common.RuleCharacteristic.ROBUST},
- {RuleCharacteristic.SECURE, Common.RuleCharacteristic.SECURE},
- {RuleCharacteristic.CONSISTENT, Common.RuleCharacteristic.CONSISTENT},
- {RuleCharacteristic.COMPLIANT, Common.RuleCharacteristic.COMPLIANT},
- {RuleCharacteristic.STRUCTURED, Common.RuleCharacteristic.STRUCTURED},
- {RuleCharacteristic.PORTABLE, Common.RuleCharacteristic.PORTABLE}
+ {CodeCharacteristic.CLEAR, Common.RuleCharacteristic.CLEAR},
+ {CodeCharacteristic.TESTED, Common.RuleCharacteristic.TESTED},
+ {CodeCharacteristic.ROBUST, Common.RuleCharacteristic.ROBUST},
+ {CodeCharacteristic.SECURE, Common.RuleCharacteristic.SECURE},
+ {CodeCharacteristic.CONSISTENT, Common.RuleCharacteristic.CONSISTENT},
+ {CodeCharacteristic.COMPLIANT, Common.RuleCharacteristic.COMPLIANT},
+ {CodeCharacteristic.STRUCTURED, Common.RuleCharacteristic.STRUCTURED},
+ {CodeCharacteristic.PORTABLE, Common.RuleCharacteristic.PORTABLE}
};
}
} \ No newline at end of file
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 c00af6fddbb..8f1654751c0 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
@@ -45,7 +45,6 @@ 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.rules.RuleCharacteristic;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.tracking.Trackable;
@@ -56,7 +55,7 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
private String key = null;
private RuleType type = null;
- private RuleCharacteristic characteristic = null;
+ private CodeCharacteristic characteristic = null;
private String componentUuid = null;
private String componentKey = null;
@@ -160,11 +159,11 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
@CheckForNull
@Override
- public RuleCharacteristic characteristic() {
+ public CodeCharacteristic characteristic() {
return characteristic;
}
- public DefaultIssue setCharacteristic(RuleCharacteristic characteristic) {
+ public DefaultIssue setCharacteristic(CodeCharacteristic characteristic) {
this.characteristic = characteristic;
return this;
}
@@ -430,7 +429,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
return this;
}
-
public DefaultIssue setNew(boolean b) {
isNew = b;
return this;
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..2cc4937bc63 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,7 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
private Long effort;
private Severity severity;
private RuleType type;
- private RuleCharacteristic characteristic;
+ private CodeCharacteristic characteristic;
private String engineId;
private String ruleId;
@@ -101,7 +101,7 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
}
@CheckForNull
- public RuleCharacteristic characteristic() {
+ public CodeCharacteristic characteristic() {
return characteristic;
}
@@ -133,7 +133,7 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
}
@Override
- public DefaultExternalIssue characteristic(RuleCharacteristic characteristic) {
+ public DefaultExternalIssue characteristic(CodeCharacteristic characteristic) {
this.characteristic = characteristic;
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 aefa37f67e7..d9027741d44 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;
@@ -36,7 +36,7 @@ public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewA
private Severity severity;
private RuleType type;
- private RuleCharacteristic characteristic;
+ private CodeCharacteristic characteristic;
private String name;
private String description;
private String engineId;
@@ -99,7 +99,7 @@ public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewA
@CheckForNull
@Override
- public RuleCharacteristic characteristic() {
+ public CodeCharacteristic characteristic() {
return characteristic;
}
@@ -134,7 +134,7 @@ public class DefaultAdHocRule extends DefaultStorable implements AdHocRule, NewA
}
@Override
- public DefaultAdHocRule characteristic(RuleCharacteristic characteristic) {
+ public DefaultAdHocRule characteristic(CodeCharacteristic characteristic) {
this.characteristic = characteristic;
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 46a9b8e8e46..bb3dfba0f20 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
@@ -30,8 +30,8 @@ import org.sonar.api.batch.fs.internal.DefaultInputProject;
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.code.CodeCharacteristic;
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;
@@ -54,7 +54,6 @@ public class DefaultExternalIssueTest {
.setWorkDir(temp.newFolder()));
}
-
private DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.php")
.initMetadata("Foo\nBar\n")
.build();
@@ -71,7 +70,7 @@ public class DefaultExternalIssueTest {
.remediationEffortMinutes(10L)
.type(RuleType.BUG)
.severity(Severity.BLOCKER)
- .characteristic(RuleCharacteristic.SECURE);
+ .characteristic(CodeCharacteristic.SECURE);
assertThat(issue.primaryLocation().inputComponent()).isEqualTo(inputFile);
assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("external_repo", "rule"));
@@ -81,7 +80,7 @@ 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.characteristic()).isEqualTo(CodeCharacteristic.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..1a0807032b1 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,7 @@ 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.code.CodeCharacteristic;
import org.sonar.api.rules.RuleType;
import static org.assertj.core.api.Assertions.assertThat;
@@ -44,7 +44,7 @@ public class DefaultAdHocRuleTest {
.description("desc")
.severity(Severity.BLOCKER)
.type(RuleType.CODE_SMELL)
- .characteristic(RuleCharacteristic.COMPLIANT);
+ .characteristic(CodeCharacteristic.COMPLIANT);
rule.save();
assertThat(rule.engineId()).isEqualTo("engine");
@@ -53,7 +53,7 @@ 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);
+ assertThat(rule.characteristic()).isEqualTo(CodeCharacteristic.COMPLIANT);
verify(storage).store(any(DefaultAdHocRule.class));
}