@Override
public void onIssue(Component component, DefaultIssue issue) {
+ if (issue.type() == RuleType.SECURITY_HOTSPOT) {
+ return;
+ }
+
currentCounters.add(issue);
if (!periodHolder.hasPeriod()) {
return;
}
void addOnPeriod(DefaultIssue issue) {
- if (issue.type() != RuleType.SECURITY_HOTSPOT) {
- counterForPeriod.add(issue);
- }
+ counterForPeriod.add(issue);
}
void add(DefaultIssue issue) {
underTest.afterComponent(FILE1);
underTest.beforeComponent(FILE2);
- underTest.onIssue(FILE1, createSecurityHotspot());
+ underTest.onIssue(FILE2, createSecurityHotspot());
underTest.afterComponent(FILE2);
underTest.beforeComponent(FILE3);
underTest.beforeComponent(PROJECT);
underTest.afterComponent(PROJECT);
- assertThat(measureRepository.getRawMeasure(FILE1, ISSUES_METRIC).get().getIntValue()).isEqualTo(2);
- assertThat(measureRepository.getRawMeasure(FILE1, OPEN_ISSUES_METRIC).get().getIntValue()).isEqualTo(2);
+ assertThat(measureRepository.getRawMeasure(FILE1, ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
+ assertThat(measureRepository.getRawMeasure(FILE1, OPEN_ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
assertThat(measureRepository.getRawMeasure(FILE1, CONFIRMED_ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
- assertThat(measureRepository.getRawMeasure(FILE2, ISSUES_METRIC).get().getIntValue()).isEqualTo(1);
- assertThat(measureRepository.getRawMeasure(FILE2, OPEN_ISSUES_METRIC).get().getIntValue()).isEqualTo(1);
+ assertThat(measureRepository.getRawMeasure(FILE2, ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
+ assertThat(measureRepository.getRawMeasure(FILE2, OPEN_ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
assertThat(measureRepository.getRawMeasure(FILE2, CONFIRMED_ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
assertThat(measureRepository.getRawMeasure(FILE3, ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
- assertThat(measureRepository.getRawMeasure(PROJECT, ISSUES_METRIC).get().getIntValue()).isEqualTo(3);
- assertThat(measureRepository.getRawMeasure(PROJECT, OPEN_ISSUES_METRIC).get().getIntValue()).isEqualTo(3);
+ assertThat(measureRepository.getRawMeasure(PROJECT, ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
+ assertThat(measureRepository.getRawMeasure(PROJECT, OPEN_ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
assertThat(measureRepository.getRawMeasure(PROJECT, CONFIRMED_ISSUES_METRIC).get().getIntValue()).isEqualTo(0);
}
import org.sonar.db.issue.IssueGroupDto;
import org.sonar.db.rule.SeverityUtil;
+import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
+
class IssueCounter {
private final Map<RuleType, HighestSeverity> highestSeverityOfUnresolved = new EnumMap<>(RuleType.class);
private long leak = 0L;
void add(IssueGroupDto group) {
- absolute += group.getCount();
- if (group.isInLeak()) {
- leak += group.getCount();
+ if (group.getRuleType() != SECURITY_HOTSPOT.getDbConstant()) {
+ absolute += group.getCount();
+ if (group.isInLeak()) {
+ leak += group.getCount();
+ }
}
}
}
newGroup(RuleType.BUG).setSeverity(Severity.MAJOR).setCount(5),
newGroup(RuleType.BUG).setSeverity(Severity.CRITICAL).setCount(7),
newGroup(RuleType.CODE_SMELL).setSeverity(Severity.BLOCKER).setCount(11),
+ // exclude security hotspot
+ newGroup(RuleType.SECURITY_HOTSPOT).setSeverity(Severity.CRITICAL).setCount(15),
// include leak
newGroup(RuleType.CODE_SMELL).setSeverity(Severity.BLOCKER).setInLeak(true).setCount(13),
// exclude resolved
newResolvedGroup(Issue.RESOLUTION_WONT_FIX, Issue.STATUS_CLOSED).setSeverity(Severity.MAJOR).setCount(7),
newResolvedGroup(Issue.RESOLUTION_WONT_FIX, Issue.STATUS_CLOSED).setSeverity(Severity.BLOCKER).setCount(11),
newResolvedGroup(Issue.RESOLUTION_REMOVED, Issue.STATUS_CLOSED).setCount(13),
+ // exclude security hotspot
+ newResolvedGroup(Issue.RESOLUTION_WONT_FIX, Issue.STATUS_RESOLVED).setCount(15).setRuleType(RuleType.SECURITY_HOTSPOT.getDbConstant()),
// exclude unresolved
newGroup(RuleType.VULNERABILITY).setCount(17),
newGroup(RuleType.BUG).setCount(19))
newGroup().setStatus(Issue.STATUS_REOPENED).setCount(7),
newGroup(RuleType.CODE_SMELL).setStatus(Issue.STATUS_OPEN).setCount(9),
newGroup(RuleType.BUG).setStatus(Issue.STATUS_OPEN).setCount(11),
+ // exclude security hotspot
+ newGroup(RuleType.SECURITY_HOTSPOT).setStatus(Issue.STATUS_OPEN).setCount(12),
newResolvedGroup(Issue.RESOLUTION_FALSE_POSITIVE, Issue.STATUS_CLOSED).setCount(13))
.assertThatValueIs(CoreMetrics.CONFIRMED_ISSUES, 3 + 5)
.assertThatValueIs(CoreMetrics.OPEN_ISSUES, 9 + 11)
with(
newGroup(RuleType.CODE_SMELL).setEffort(3.0).setInLeak(false),
newGroup(RuleType.CODE_SMELL).setEffort(5.0).setInLeak(true),
+ // exclude security hotspot
+ newGroup(RuleType.SECURITY_HOTSPOT).setEffort(9).setInLeak(true),
+ newGroup(RuleType.SECURITY_HOTSPOT).setEffort(11).setInLeak(false),
// not code smells
newGroup(RuleType.BUG).setEffort(7.0),
// exclude resolved
// not in leak
newGroup(RuleType.CODE_SMELL).setEffort(5.0).setInLeak(false),
// not code smells
+ newGroup(RuleType.SECURITY_HOTSPOT).setEffort(9.0).setInLeak(true),
newGroup(RuleType.BUG).setEffort(7.0).setInLeak(true),
// exclude resolved
newResolvedGroup(RuleType.CODE_SMELL).setEffort(17.0).setInLeak(true))