use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class EffortAggregatorTest method maintainability_effort_is_only_computed_using_code_smell_issues.
@Test
public void maintainability_effort_is_only_computed_using_code_smell_issues() {
DefaultIssue codeSmellIssue = newCodeSmellIssue(10);
// Issues of type BUG and VULNERABILITY should be ignored
DefaultIssue bugIssue = newBugIssue(15);
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(12);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, codeSmellIssue);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.afterComponent(FILE);
// Only effort of CODE SMELL issue is used
assertMeasure(FILE, TECHNICAL_DEBT_KEY, 10L);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class EffortAggregatorTest method sum_security_effort_of_unresolved_issues.
@Test
public void sum_security_effort_of_unresolved_issues() {
DefaultIssue unresolved1 = newVulnerabilityIssue(10);
DefaultIssue unresolved2 = newVulnerabilityIssue(30);
DefaultIssue unresolvedWithoutEffort = newVulnerabilityIssueWithoutEffort();
DefaultIssue resolved = newVulnerabilityIssue(50).setResolution(RESOLUTION_FIXED);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, unresolved1);
underTest.onIssue(FILE, unresolved2);
underTest.onIssue(FILE, unresolvedWithoutEffort);
underTest.onIssue(FILE, resolved);
underTest.afterComponent(FILE);
assertMeasure(FILE, SECURITY_REMEDIATION_EFFORT_KEY, 10L + 30L);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IntegrateIssuesVisitorTest method process_existing_issue.
@Test
public void process_existing_issue() throws Exception {
componentsWithUnprocessedIssues.setUuids(newHashSet(FILE_UUID));
RuleKey ruleKey = RuleTesting.XOO_X1;
// Issue from db has severity major
addBaseIssue(ruleKey);
// Issue from report has severity blocker
ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder().setMsg("the message").setRuleRepository(ruleKey.repository()).setRuleKey(ruleKey.rule()).setSeverity(Constants.Severity.BLOCKER).build();
reportReader.putIssues(FILE_REF, asList(reportIssue));
fileSourceRepository.addLine(FILE_REF, "line1");
underTest.visitAny(FILE);
ArgumentCaptor<DefaultIssue> rawIssueCaptor = ArgumentCaptor.forClass(DefaultIssue.class);
ArgumentCaptor<DefaultIssue> baseIssueCaptor = ArgumentCaptor.forClass(DefaultIssue.class);
verify(issueLifecycle).mergeExistingOpenIssue(rawIssueCaptor.capture(), baseIssueCaptor.capture());
assertThat(rawIssueCaptor.getValue().severity()).isEqualTo(Severity.BLOCKER);
assertThat(baseIssueCaptor.getValue().severity()).isEqualTo(Severity.MAJOR);
verify(issueLifecycle).doAutomaticTransition(defaultIssueCaptor.capture());
assertThat(defaultIssueCaptor.getValue().ruleKey()).isEqualTo(ruleKey);
List<DefaultIssue> issues = newArrayList(issueCache.traverse());
assertThat(issues).hasSize(1);
assertThat(issues.get(0).severity()).isEqualTo(Severity.BLOCKER);
assertThat(componentsWithUnprocessedIssues.getUuids()).isEmpty();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IntegrateIssuesVisitorTest method close_unmatched_base_issue.
@Test
public void close_unmatched_base_issue() throws Exception {
componentsWithUnprocessedIssues.setUuids(newHashSet(FILE_UUID));
RuleKey ruleKey = RuleTesting.XOO_X1;
addBaseIssue(ruleKey);
// No issue in the report
underTest.visitAny(FILE);
verify(issueLifecycle).doAutomaticTransition(defaultIssueCaptor.capture());
assertThat(defaultIssueCaptor.getValue().isBeingClosed()).isTrue();
List<DefaultIssue> issues = newArrayList(issueCache.traverse());
assertThat(issues).hasSize(1);
assertThat(componentsWithUnprocessedIssues.getUuids()).isEmpty();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueAssignerTest method set_last_committer_when_line_is_bigger_than_changeset_size.
@Test
public void set_last_committer_when_line_is_bigger_than_changeset_size() throws Exception {
addScmUser("john", "John C");
Changeset changeset = Changeset.newChangesetBuilder().setAuthor("john").setDate(123456789L).setRevision("rev-1").build();
scmInfoRepository.setScmInfo(FILE_REF, changeset, changeset);
DefaultIssue issue = new DefaultIssue().setLine(3);
underTest.onIssue(FILE, issue);
assertThat(issue.assignee()).isEqualTo("John C");
}
Aggregations