diff options
author | Janos Gyerik <janos.gyerik@sonarsource.com> | 2018-07-04 11:29:06 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-07-17 20:21:23 +0200 |
commit | 3785b1a0c0c8d3c362d8a35eb12a1ff94ccc00c2 (patch) | |
tree | 97f252b5b86232de9eb050c729d429792e6f67f1 /server | |
parent | 57194b3970a2ccc028141bc388d303cd50a31fc2 (diff) | |
download | sonarqube-3785b1a0c0c8d3c362d8a35eb12a1ff94ccc00c2.tar.gz sonarqube-3785b1a0c0c8d3c362d8a35eb12a1ff94ccc00c2.zip |
Remove security hotspot measures
Diffstat (limited to 'server')
4 files changed, 4 insertions, 31 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java index 5f784137045..17e1df16efb 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java @@ -30,7 +30,6 @@ import org.sonar.api.measures.CoreMetrics; import org.sonar.api.rules.RuleType; import org.sonar.ce.task.projectanalysis.component.Component; import org.sonar.core.issue.DefaultIssue; -import org.sonar.ce.task.projectanalysis.component.Component; import org.sonar.ce.task.projectanalysis.measure.Measure; import org.sonar.ce.task.projectanalysis.measure.MeasureRepository; import org.sonar.ce.task.projectanalysis.metric.Metric; @@ -97,13 +96,11 @@ public class IssueCounter extends IssueVisitor { .put(RuleType.CODE_SMELL, CoreMetrics.CODE_SMELLS_KEY) .put(RuleType.BUG, CoreMetrics.BUGS_KEY) .put(RuleType.VULNERABILITY, CoreMetrics.VULNERABILITIES_KEY) - .put(RuleType.SECURITY_HOTSPOT, CoreMetrics.SECURITY_HOTSPOTS_KEY) .build(); private static final Map<RuleType, String> TYPE_TO_NEW_METRIC_KEY = ImmutableMap.<RuleType, String>builder() .put(RuleType.CODE_SMELL, CoreMetrics.NEW_CODE_SMELLS_KEY) .put(RuleType.BUG, CoreMetrics.NEW_BUGS_KEY) .put(RuleType.VULNERABILITY, CoreMetrics.NEW_VULNERABILITIES_KEY) - .put(RuleType.SECURITY_HOTSPOT, CoreMetrics.NEW_SECURITY_HOTSPOTS_KEY) .build(); private final PeriodHolder periodHolder; @@ -264,12 +261,6 @@ public class IssueCounter extends IssueVisitor { // Other statuses are ignored } } - - void addNewSecurityHotspot(DefaultIssue issue) { - if (issue.resolution() == null) { - typeBag.add(issue.type()); - } - } } /** @@ -289,8 +280,6 @@ public class IssueCounter extends IssueVisitor { void addOnPeriod(DefaultIssue issue) { if (issue.type() != RuleType.SECURITY_HOTSPOT) { counterForPeriod.add(issue); - } else { - counterForPeriod.addNewSecurityHotspot(issue); } } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueCounterTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueCounterTest.java index 45f2049e187..0794d75dea3 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueCounterTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueCounterTest.java @@ -101,8 +101,6 @@ public class IssueCounterTest { static final Metric NEW_CODE_SMELLS_METRIC = new MetricImpl(20, CoreMetrics.NEW_CODE_SMELLS_KEY, CoreMetrics.NEW_CODE_SMELLS_KEY, INT); static final Metric NEW_BUGS_METRIC = new MetricImpl(21, CoreMetrics.NEW_BUGS_KEY, CoreMetrics.NEW_BUGS_KEY, INT); static final Metric NEW_VULNERABILITIES_METRIC = new MetricImpl(22, CoreMetrics.NEW_VULNERABILITIES_KEY, CoreMetrics.NEW_VULNERABILITIES_KEY, INT); - static final Metric SECURITY_HOTSPOTS_METRIC = new MetricImpl(24, CoreMetrics.SECURITY_HOTSPOTS_KEY, CoreMetrics.SECURITY_HOTSPOTS_KEY, INT); - static final Metric NEW_SECURITY_HOTSPOTS_METRIC = new MetricImpl(25, CoreMetrics.NEW_SECURITY_HOTSPOTS_KEY, CoreMetrics.NEW_SECURITY_HOTSPOTS_KEY, INT); @Rule public BatchReportReaderRule reportReader = new BatchReportReaderRule(); @@ -137,9 +135,7 @@ public class IssueCounterTest { .add(VULNERABILITIES_METRIC) .add(NEW_CODE_SMELLS_METRIC) .add(NEW_BUGS_METRIC) - .add(NEW_VULNERABILITIES_METRIC) - .add(SECURITY_HOTSPOTS_METRIC) - .add(NEW_SECURITY_HOTSPOTS_METRIC); + .add(NEW_VULNERABILITIES_METRIC); @Rule public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository); @@ -325,7 +321,7 @@ public class IssueCounterTest { } @Test - public void count_hotspots() { + public void exclude_hotspots_from_issue_counts() { periodsHolder.setPeriod(null); // bottom-up traversal -> from files to project @@ -344,27 +340,23 @@ public class IssueCounterTest { underTest.beforeComponent(PROJECT); underTest.afterComponent(PROJECT); - assertThat(measureRepository.getRawMeasure(FILE1, SECURITY_HOTSPOTS_METRIC).get().getIntValue()).isEqualTo(2); 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, CONFIRMED_ISSUES_METRIC).get().getIntValue()).isEqualTo(0); - assertThat(measureRepository.getRawMeasure(FILE2, SECURITY_HOTSPOTS_METRIC).get().getIntValue()).isEqualTo(1); 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, CONFIRMED_ISSUES_METRIC).get().getIntValue()).isEqualTo(0); - assertThat(measureRepository.getRawMeasure(FILE3, SECURITY_HOTSPOTS_METRIC).get().getIntValue()).isEqualTo(0); assertThat(measureRepository.getRawMeasure(FILE3, ISSUES_METRIC).get().getIntValue()).isEqualTo(0); - assertThat(measureRepository.getRawMeasure(PROJECT, SECURITY_HOTSPOTS_METRIC).get().getIntValue()).isEqualTo(3); 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, CONFIRMED_ISSUES_METRIC).get().getIntValue()).isEqualTo(0); } @Test - public void count_new_hotspots_excluded_from_other_raw_issue_counts() { + public void exclude_new_hotspots_from_issue_counts() { Period period = newPeriod(1500000000000L); periodsHolder.setPeriod(period); @@ -395,14 +387,12 @@ public class IssueCounterTest { assertVariation(FILE1, NEW_BLOCKER_ISSUES_METRIC, 0); assertVariation(FILE1, NEW_MAJOR_ISSUES_METRIC, 0); assertVariation(FILE1, NEW_VULNERABILITIES_METRIC, 0); - assertVariation(FILE1, NEW_SECURITY_HOTSPOTS_METRIC, 3); assertVariation(PROJECT, NEW_ISSUES_METRIC, 0); assertVariation(PROJECT, NEW_CRITICAL_ISSUES_METRIC, 0); assertVariation(PROJECT, NEW_BLOCKER_ISSUES_METRIC, 0); assertVariation(PROJECT, NEW_MAJOR_ISSUES_METRIC, 0); assertVariation(PROJECT, NEW_VULNERABILITIES_METRIC, 0); - assertVariation(PROJECT, NEW_SECURITY_HOTSPOTS_METRIC, 3); } private void assertVariation(Component component, Metric metric, int expectedVariation) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/live/IssueMetricFormulaFactoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/measure/live/IssueMetricFormulaFactoryImpl.java index 756ecf80404..def6ce168c0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/live/IssueMetricFormulaFactoryImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/live/IssueMetricFormulaFactoryImpl.java @@ -44,9 +44,6 @@ public class IssueMetricFormulaFactoryImpl implements IssueMetricFormulaFactory new IssueMetricFormula(CoreMetrics.VULNERABILITIES, false, (context, issues) -> context.setValue(issues.countUnresolvedByType(RuleType.VULNERABILITY, false))), - new IssueMetricFormula(CoreMetrics.SECURITY_HOTSPOTS, false, - (context, issues) -> context.setValue(issues.countUnresolvedByType(RuleType.SECURITY_HOTSPOT, false))), - new IssueMetricFormula(CoreMetrics.VIOLATIONS, false, (context, issues) -> context.setValue(issues.countUnresolved(false))), @@ -116,9 +113,6 @@ public class IssueMetricFormulaFactoryImpl implements IssueMetricFormulaFactory new IssueMetricFormula(CoreMetrics.NEW_VULNERABILITIES, true, (context, issues) -> context.setLeakValue(issues.countUnresolvedByType(RuleType.VULNERABILITY, true))), - new IssueMetricFormula(CoreMetrics.NEW_SECURITY_HOTSPOTS, true, - (context, issues) -> context.setLeakValue(issues.countUnresolvedByType(RuleType.SECURITY_HOTSPOT, true))), - new IssueMetricFormula(CoreMetrics.NEW_VIOLATIONS, true, (context, issues) -> context.setLeakValue(issues.countUnresolved(true))), diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx index 7e00a59b32d..7a41a9ef001 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx @@ -39,7 +39,7 @@ export default function MeasuresOverlayMeasure({ measure }: Props) { data-metric={measure.metric.key} key={measure.metric.key}> <span className="measure-name"> - {['bugs', 'vulnerabilities', 'code_smells', 'security_hotspots'].includes(measure.metric.key) && ( + {['bugs', 'vulnerabilities', 'code_smells'].includes(measure.metric.key) && ( <IssueTypeIcon className="little-spacer-right" query={measure.metric.key} /> )} {getLocalizedMetricName(measure.metric)} |