use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class SkippedTestRuleTest method no_issues_if_measure_is_absent.
@Test
public void no_issues_if_measure_is_absent() throws Exception {
activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap(), 1_000L));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue).isNull();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class TrackerRawInputFactoryTest method load_issues_of_compute_engine_common_rules.
@Test
public void load_issues_of_compute_engine_common_rules() throws Exception {
when(issueFilter.accept(any(DefaultIssue.class), eq(FILE))).thenReturn(true);
fileSourceRepository.addLines(FILE_REF, "line 1;", "line 2;");
DefaultIssue ceIssue = new DefaultIssue().setRuleKey(RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), "InsufficientCoverage")).setMessage("not enough coverage").setGap(10.0);
when(commonRuleEngine.process(FILE)).thenReturn(asList(ceIssue));
Input<DefaultIssue> input = underTest.create(FILE);
assertThat(input.getIssues()).containsOnly(ceIssue);
assertInitializedIssue(input.getIssues().iterator().next());
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class UpdateConflictResolverTest method should_keep_changes_made_by_user.
@Test
public void should_keep_changes_made_by_user() {
DefaultIssue issue = new DefaultIssue().setKey("ABCDE").setRuleKey(RuleKey.of("squid", "AvoidCycles")).setComponentKey("struts:org.apache.struts.Action").setNew(false);
// Before starting scan
issue.setAssignee(null);
issue.setCreationDate(DateUtils.parseDate("2012-01-01"));
issue.setUpdateDate(DateUtils.parseDate("2012-02-02"));
// Changed by scan
issue.setLine(200);
issue.setSeverity(Severity.BLOCKER);
issue.setManualSeverity(false);
issue.setAuthorLogin("simon");
issue.setChecksum("CHECKSUM-ABCDE");
issue.setResolution(null);
issue.setStatus(Issue.STATUS_REOPENED);
// Issue as seen and changed by end-user
IssueDto dbIssue = new IssueDto().setKee("ABCDE").setRuleId(10).setRuleKey("squid", "AvoidCycles").setComponentUuid("100").setComponentKey("struts:org.apache.struts.Action").setLine(10).setResolution(Issue.RESOLUTION_FALSE_POSITIVE).setStatus(Issue.STATUS_RESOLVED).setAssignee("arthur").setSeverity(Severity.MAJOR).setManualSeverity(false);
new UpdateConflictResolver().mergeFields(dbIssue, issue);
assertThat(issue.key()).isEqualTo("ABCDE");
assertThat(issue.componentKey()).isEqualTo("struts:org.apache.struts.Action");
// Scan wins on :
assertThat(issue.line()).isEqualTo(200);
assertThat(issue.severity()).isEqualTo(Severity.BLOCKER);
assertThat(issue.manualSeverity()).isFalse();
// User wins on :
assertThat(issue.assignee()).isEqualTo("arthur");
assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FALSE_POSITIVE);
assertThat(issue.status()).isEqualTo(Issue.STATUS_RESOLVED);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class CommentDensityRuleTest method issue_if_not_enough_comments__test_ceil.
@Test
public void issue_if_not_enough_comments__test_ceil() {
activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, ImmutableMap.of(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY, "25"), 1_000L));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.COMMENT_LINES_DENSITY_KEY, Measure.newMeasureBuilder().create(0.0, 1));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.COMMENT_LINES_KEY, Measure.newMeasureBuilder().create(0));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.NCLOC_KEY, Measure.newMeasureBuilder().create(1));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue.ruleKey()).isEqualTo(RULE_KEY);
assertThat(issue.severity()).isEqualTo(Severity.CRITICAL);
// 1 ncloc requires 1 comment line to reach 25% of comment density
assertThat(issue.effortToFix()).isEqualTo(1.0);
assertThat(issue.message()).isEqualTo("1 more comment lines need to be written to reach the minimum threshold of 25.0% comment density.");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class CommentDensityRuleTest method no_issues_if_enough_comments.
@Test
public void no_issues_if_enough_comments() {
activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, ImmutableMap.of(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY, "25"), 1_000L));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.COMMENT_LINES_DENSITY_KEY, Measure.newMeasureBuilder().create(90.0, 1));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue).isNull();
}
Aggregations