diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2023-04-26 11:00:27 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-04-28 20:02:58 +0000 |
commit | 4346b3aee97552c11d0cbe6e1af14175fa3441dc (patch) | |
tree | d0496b29fb91f51ab60f4db6e2ed04d4f7893db3 | |
parent | 9b1d4caa245598fc12668ef6a9d282a1f97ee9d6 (diff) | |
download | sonarqube-4346b3aee97552c11d0cbe6e1af14175fa3441dc.tar.gz sonarqube-4346b3aee97552c11d0cbe6e1af14175fa3441dc.zip |
Revert "SONAR-19050 Add rule type rule characteristic to issue dto"
This reverts commit eed7da3c1faadf0684cf66a110359ef0fa4d5d52.
7 files changed, 7 insertions, 70 deletions
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..c83cf5a4850 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 @@ -28,7 +28,6 @@ import java.util.stream.Stream; import org.junit.Rule; import org.junit.Test; 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; @@ -123,9 +122,6 @@ public class IssueDaoIT { assertThat(issue.getLocations()).isNull(); 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); 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 117f5a9b054..498680a1873 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 @@ -56,7 +56,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"; @@ -457,7 +456,6 @@ public class RuleDaoIT { .setSystemTags(newHashSet("systag1", "systag2")) .setSecurityStandards(newHashSet("owaspTop10:a1", "cwe:123")) .setType(RuleType.BUG) - .setCharacteristic(CLEAR) .setScope(Scope.ALL) .setCreatedAt(1_500_000_000_000L) .setUpdatedAt(2_000_000_000_000L); @@ -485,8 +483,6 @@ 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(CLEAR); - 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); 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 10d8ce24748..10a8a1620c4 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 @@ -19,7 +19,6 @@ */ package org.sonar.db.issue; -import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Splitter; @@ -35,7 +34,6 @@ import javax.annotation.Nullable; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; 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; @@ -46,7 +44,6 @@ import org.sonar.db.rule.RuleDto; import static com.google.common.base.Preconditions.checkArgument; import static org.sonar.api.utils.DateUtils.dateToLong; import static org.sonar.api.utils.DateUtils.longToDate; -import static org.sonar.db.rule.RuleTypeToRuleCharacteristicConverter.convertToRuleCharacteristic; public final class IssueDto implements Serializable { @@ -56,8 +53,6 @@ public final class IssueDto implements Serializable { private static final Splitter TAGS_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings(); private int type; - private int ruleType; - private RuleCharacteristic ruleCharacteristic; private String kee; private String componentUuid; private String projectUuid; @@ -715,37 +710,6 @@ public final class IssueDto implements Serializable { return this; } - @CheckForNull - public RuleCharacteristic getRuleCharacteristic() { - return ruleCharacteristic; - } - - @VisibleForTesting - IssueDto setRuleCharacteristic(RuleCharacteristic ruleCharacteristic) { - this.ruleCharacteristic = ruleCharacteristic; - return this; - } - - @CheckForNull - public RuleCharacteristic getEffectiveRuleCharacteristic() { - return ruleCharacteristic != null ? ruleCharacteristic : convertTypeToCharacteristic(ruleType); - } - - private static RuleCharacteristic convertTypeToCharacteristic(int type) { - RuleType ruleType = RuleType.valueOf(type); - return convertToRuleCharacteristic(ruleType); - } - - public int getRuleType() { - return ruleType; - } - - @VisibleForTesting - IssueDto setRuleType(int ruleType) { - this.ruleType = ruleType; - return this; - } - public Optional<String> getClosedChangeData() { return Optional.ofNullable(closedChangeData); } 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 d9771995881..83ea4486693 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 @@ -32,8 +32,6 @@ r.plugin_name as ruleRepo, r.language as language, r.security_standards as securityStandards, - r.rule_type as ruleType, - r.characteristic as ruleCharacteristic, p.kee as componentKey, i.component_uuid as componentUuid, p.path as filePath, diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml index e481e9a3930..ca8352d9cd8 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml @@ -261,7 +261,6 @@ system_tags, security_standards, rule_type, - characteristic, scope, note_data, note_user_uuid, @@ -301,7 +300,6 @@ #{systemTagsField,jdbcType=VARCHAR}, #{securityStandardsField,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, - #{characteristic,jdbcType=VARCHAR}, #{scope,jdbcType=VARCHAR}, #{noteData,jdbcType=CLOB}, #{noteUserUuid,jdbcType=VARCHAR}, 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..e7ecde67266 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 @@ -29,7 +29,6 @@ import org.apache.commons.lang.time.DateUtils; import org.junit.Test; 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; @@ -156,19 +155,19 @@ public class IssueDtoTest { assertThat(issueDto).extracting(IssueDto::getKey, IssueDto::getType, IssueDto::getRuleKey).containsExactly("key", RuleType.BUG.getDbConstant(), RuleKey.of("repo", "rule")); assertThat(issueDto).extracting(IssueDto::getIssueCreationDate, IssueDto::getIssueCloseDate, - IssueDto::getIssueUpdateDate, IssueDto::getSelectedAt, IssueDto::getUpdatedAt, IssueDto::getCreatedAt) + IssueDto::getIssueUpdateDate, IssueDto::getSelectedAt, IssueDto::getUpdatedAt, IssueDto::getCreatedAt) .containsExactly(dateNow, dateNow, dateNow, dateNow.getTime(), now, now); assertThat(issueDto).extracting(IssueDto::getLine, IssueDto::getMessage, - IssueDto::getGap, IssueDto::getEffort, IssueDto::getResolution, IssueDto::getStatus, IssueDto::getSeverity) + IssueDto::getGap, IssueDto::getEffort, IssueDto::getResolution, IssueDto::getStatus, IssueDto::getSeverity) .containsExactly(1, "message", 1.0, 1L, Issue.RESOLUTION_FALSE_POSITIVE, Issue.STATUS_CLOSED, "BLOCKER"); assertThat(issueDto).extracting(IssueDto::getTags, IssueDto::getAuthorLogin) .containsExactly(Set.of("todo"), "admin"); assertThat(issueDto).extracting(IssueDto::isManualSeverity, IssueDto::getChecksum, IssueDto::getAssigneeUuid, - IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey, - IssueDto::getProjectUuid, IssueDto::getProjectKey, IssueDto::getRuleUuid) + IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey, + IssueDto::getProjectUuid, IssueDto::getProjectKey, IssueDto::getRuleUuid) .containsExactly(true, "123", "123", true, "123", "componentKey", "123", "projectKey", "ruleUuid"); assertThat(issueDto.isQuickFixAvailable()).isTrue(); @@ -187,18 +186,18 @@ public class IssueDtoTest { assertThat(issueDto).extracting(IssueDto::getKey, IssueDto::getType, IssueDto::getRuleKey).containsExactly("key", RuleType.BUG.getDbConstant(), RuleKey.of("repo", "rule")); assertThat(issueDto).extracting(IssueDto::getIssueCreationDate, IssueDto::getIssueCloseDate, - IssueDto::getIssueUpdateDate, IssueDto::getSelectedAt, IssueDto::getUpdatedAt) + IssueDto::getIssueUpdateDate, IssueDto::getSelectedAt, IssueDto::getUpdatedAt) .containsExactly(dateNow, dateNow, dateNow, dateNow.getTime(), now); assertThat(issueDto).extracting(IssueDto::getLine, IssueDto::getMessage, - IssueDto::getGap, IssueDto::getEffort, IssueDto::getResolution, IssueDto::getStatus, IssueDto::getSeverity) + IssueDto::getGap, IssueDto::getEffort, IssueDto::getResolution, IssueDto::getStatus, IssueDto::getSeverity) .containsExactly(1, "message", 1.0, 1L, Issue.RESOLUTION_FALSE_POSITIVE, Issue.STATUS_CLOSED, "BLOCKER"); assertThat(issueDto).extracting(IssueDto::getTags, IssueDto::getAuthorLogin) .containsExactly(Set.of("todo"), "admin"); assertThat(issueDto).extracting(IssueDto::isManualSeverity, IssueDto::getChecksum, IssueDto::getAssigneeUuid, - IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey, IssueDto::getProjectUuid, IssueDto::getProjectKey) + IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey, IssueDto::getProjectUuid, IssueDto::getProjectKey) .containsExactly(true, "123", "123", true, "123", "componentKey", "123", "projectKey"); assertThat(issueDto.isQuickFixAvailable()).isTrue(); @@ -237,16 +236,4 @@ public class IssueDtoTest { .setRuleDescriptionContextKey(TEST_CONTEXT_KEY); return defaultIssue; } - - @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); - } - - @Test - public void getEffectiveCharacteristic_when_characteristicNotInitialized_should_return_characteristicDbConstantValue() { - IssueDto issueDto = new IssueDto().setRuleType(RuleType.CODE_SMELL.getDbConstant()); - assertThat(issueDto.getEffectiveRuleCharacteristic()).isEqualTo(RuleCharacteristic.CLEAR); - } } 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 7cc01d1ec50..6d5cc8f4cfd 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 @@ -26,7 +26,6 @@ import javax.annotation.Nullable; 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; @@ -93,7 +92,6 @@ public class RuleTesting { .setName("name_" + randomAlphanumeric(5)) .setDescriptionFormat(RuleDto.Format.HTML) .setType(CODE_SMELL) - .setCharacteristic(RuleCharacteristic.CLEAR) .setStatus(RuleStatus.READY) .setConfigKey("configKey_" + ruleKey.rule()) .setSeverity(Severity.ALL.get(nextInt(Severity.ALL.size()))) |