IssueDto issue = underTest.selectOrFailByKey(db.getSession(), ISSUE_KEY1);
assertThat(issue).usingRecursiveComparison()
- .ignoringFields("filePath", "issueCreationDate", "issueUpdateDate", "issueCloseDate")
+ .ignoringFields("filePath", "issueCreationDate", "issueUpdateDate", "issueCloseDate", "cleanCodeAttribute")
.isEqualTo(expected);
assertThat(issue.parseMessageFormattings()).isEqualTo(MESSAGE_FORMATTING);
assertThat(issue.getIssueCreationDate()).isNotNull();
assertThat(issue.getIssueCloseDate()).isNotNull();
assertThat(issue.getRuleRepo()).isEqualTo(RULE.getRepositoryKey());
assertThat(issue.getRule()).isEqualTo(RULE.getRuleKey());
+ assertThat(issue.getCleanCodeAttribute()).isEqualTo(RULE.getCleanCodeAttribute());
assertThat(issue.parseLocations()).isNull();
}
dto.setCodeVariants(Set.of("variant1", "variant2"));
return dto;
}
+
private void prepareTables() {
underTest.insert(db.getSession(), newIssueDto(ISSUE_KEY1)
.setMessage("the message")
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
+import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleQuery;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.debt.DebtRemediationFunction;
assertThat(actual.getRuleDescriptionSectionDtos()).usingRecursiveFieldByFieldElementComparator()
.containsExactlyInAnyOrderElementsOf(expected.getRuleDescriptionSectionDtos());
assertThat(actual.getEducationPrinciples()).isEqualTo(expected.getEducationPrinciples());
+ assertThat(actual.getCleanCodeAttribute()).isEqualTo(expected.getCleanCodeAttribute());
}
@Test
.setSystemTags(newHashSet("systag1", "systag2"))
.setSecurityStandards(newHashSet("owaspTop10:a1", "cwe:123"))
.setType(RuleType.BUG)
+ .setCleanCodeAttribute(CleanCodeAttribute.CLEAR)
.setScope(Scope.ALL)
.setCreatedAt(1_500_000_000_000L)
.setUpdatedAt(2_000_000_000_000L);
assertThat(ruleDto.getDescriptionFormat()).isEqualTo(RuleDto.Format.MARKDOWN);
assertThat(ruleDto.getRuleDescriptionSectionDtos()).usingRecursiveFieldByFieldElementComparator()
.containsOnly(sectionDto);
+ assertThat(ruleDto.getCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.CLEAR);
}
@Test
.setSecurityStandards(newHashSet("owaspTop10:a1", "cwe:123"))
.setScope(Scope.ALL)
.setType(RuleType.BUG)
+ .setCleanCodeAttribute(CleanCodeAttribute.TRUSTWORTHY)
.setUpdatedAt(2_000_000_000_000L);
underTest.update(db.getSession(), ruleToUpdate);
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.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
private static final Splitter STRING_LIST_SPLITTER = Splitter.on(STRING_LIST_SEPARATOR).trimResults().omitEmptyStrings();
private int type;
+ private CleanCodeAttribute cleanCodeAttribute;
private String kee;
private String componentUuid;
private String projectUuid;
this.ruleRepo = rule.getRepositoryKey();
this.language = rule.getLanguage();
this.isExternal = rule.isExternal();
+ this.cleanCodeAttribute = rule.getCleanCodeAttribute();
return this;
}
return this;
}
+ public CleanCodeAttribute getCleanCodeAttribute() {
+ return cleanCodeAttribute;
+ }
+
+ public IssueDto setCleanCodeAttribute(CleanCodeAttribute cleanCodeAttribute) {
+ this.cleanCodeAttribute = cleanCodeAttribute;
+ return this;
+ }
+
public Optional<String> getClosedChangeData() {
return Optional.ofNullable(closedChangeData);
}
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
+import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import static com.google.common.base.Preconditions.checkArgument;
private String systemTagsField = null;
private String securityStandardsField = null;
private int type = 0;
+ private CleanCodeAttribute cleanCodeAttribute = null;
private Scope scope = null;
private RuleKey key = null;
return deserializeStringSet(educationPrinciplesField);
}
- public RuleDto setEducationPrinciples(Set<String> educationPrinciples){
+ public RuleDto setEducationPrinciples(Set<String> educationPrinciples) {
this.educationPrinciplesField = serializeStringSet(educationPrinciples);
return this;
}
return this;
}
+ public CleanCodeAttribute getCleanCodeAttribute() {
+ return cleanCodeAttribute;
+ }
+
+ public RuleDto setCleanCodeAttribute(CleanCodeAttribute cleanCodeAttribute) {
+ this.cleanCodeAttribute = cleanCodeAttribute;
+ return this;
+ }
+
public long getCreatedAt() {
return createdAt;
}
r.plugin_name as ruleRepo,
r.language as language,
r.security_standards as securityStandards,
+ r.clean_code_attribute as cleanCodeAttribute,
p.kee as componentKey,
i.component_uuid as componentUuid,
p.path as filePath,
r.rule_type as ruleType,
r.plugin_name as ruleRepo,
r.plugin_rule_key as ruleKey,
+ r.clean_code_attribute as cleanCodeAttribute,
i.message as message,
i.message_formattings as messageFormattings,
i.severity as severity,
r.ad_hoc_description as "adHocDescription",
r.ad_hoc_severity as "adHocSeverity",
r.ad_hoc_type as "adHocType",
- r.education_principles as "educationPrinciplesField"
+ r.education_principles as "educationPrinciplesField",
+ r.clean_code_attribute as "cleanCodeAttribute"
</sql>
<sql id="leftOuterJoinRulesDescriptionSections">
ad_hoc_severity,
ad_hoc_type,
education_principles,
+ clean_code_attribute,
created_at,
updated_at
)
#{adHocSeverity,jdbcType=VARCHAR},
#{adHocType,jdbcType=TINYINT},
#{educationPrinciplesField,jdbcType=VARCHAR},
+ #{cleanCodeAttribute,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT}
)
ad_hoc_severity=#{adHocSeverity,jdbcType=VARCHAR},
ad_hoc_type=#{adHocType,jdbcType=TINYINT},
education_principles=#{educationPrinciplesField,jdbcType=VARCHAR},
+ clean_code_attribute=#{cleanCodeAttribute,jdbcType=VARCHAR},
updated_at=#{updatedAt,jdbcType=BIGINT}
where
uuid=#{uuid,jdbcType=VARCHAR}
import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
public void set_rule() {
IssueDto dto = new IssueDto()
.setKee("100")
- .setRule(new RuleDto().setUuid("uuid-1").setRuleKey("AvoidCycle").setRepositoryKey("java").setIsExternal(true))
+ .setRule(new RuleDto().setUuid("uuid-1").setRuleKey("AvoidCycle").setRepositoryKey("java").setIsExternal(true).setCleanCodeAttribute(CleanCodeAttribute.CLEAR))
.setLanguage("xoo");
assertThat(dto.getRuleUuid()).isEqualTo("uuid-1");
assertThat(dto.getRuleRepo()).isEqualTo("java");
assertThat(dto.getRule()).isEqualTo("AvoidCycle");
assertThat(dto.getRuleKey()).hasToString("java:AvoidCycle");
+ assertThat(dto.getCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.CLEAR);
assertThat(dto.getLanguage()).isEqualTo("xoo");
assertThat(dto.isExternal()).isTrue();
}
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
+import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RuleParamType;
import org.sonar.core.util.UuidFactory;
.setName("name_" + randomAlphanumeric(5))
.setDescriptionFormat(RuleDto.Format.HTML)
.setType(CODE_SMELL)
+ .setCleanCodeAttribute(CleanCodeAttribute.CLEAR)
.setStatus(RuleStatus.READY)
.setConfigKey("configKey_" + ruleKey.rule())
.setSeverity(Severity.ALL.get(nextInt(Severity.ALL.size())))