diff options
13 files changed, 46 insertions, 241 deletions
diff --git a/it/it-tests/src/test/java/it/Category1Suite.java b/it/it-tests/src/test/java/it/Category1Suite.java index db792a9a014..65ff384d431 100644 --- a/it/it-tests/src/test/java/it/Category1Suite.java +++ b/it/it-tests/src/test/java/it/Category1Suite.java @@ -46,8 +46,6 @@ import it.projectAdministration.ProjectAdministrationTest; import it.qualityGate.QualityGateNotificationTest; import it.qualityGate.QualityGateTest; import it.qualityGate.QualityGateUiTest; -import it.qualityModel.NewDebtRatioMeasureTest; -import it.qualityModel.TechnicalDebtMeasureVariationTest; import it.settings.PropertySetsTest; import it.settings.SettingsTest; import it.settings.SubCategoriesTest; @@ -90,13 +88,11 @@ import static util.ItUtils.xooPlugin; // custom measure CustomMeasuresTest.class, // measure - NewDebtRatioMeasureTest.class, ProjectMeasuresPageTest.class, ProjectOverviewTest.class, ProjectWidgetsTest.class, MeasureFiltersTest.class, MeasuresWsTest.class, - TechnicalDebtMeasureVariationTest.class, // measure history DifferentialPeriodsTest.class, HistoryUiTest.class, diff --git a/it/it-tests/src/test/java/it/Category2Suite.java b/it/it-tests/src/test/java/it/Category2Suite.java index b9fe3cd661b..247a001df22 100644 --- a/it/it-tests/src/test/java/it/Category2Suite.java +++ b/it/it-tests/src/test/java/it/Category2Suite.java @@ -35,7 +35,11 @@ import it.issue.IssueWorkflowTest; import it.issue.NewIssuesMeasureTest; import it.qualityModel.MaintainabilityMeasureTest; import it.qualityModel.MaintainabilityRatingMeasureTest; +import it.qualityModel.NewDebtRatioMeasureTest; +import it.qualityModel.ReliabilityMeasureTest; +import it.qualityModel.SecurityMeasureTest; import it.qualityModel.TechnicalDebtInIssueChangelogTest; +import it.qualityModel.TechnicalDebtMeasureVariationTest; import it.qualityModel.TechnicalDebtTest; import it.qualityModel.TechnicalDebtWidgetTest; import it.test.CoverageTest; @@ -71,9 +75,13 @@ import static util.ItUtils.xooPlugin; IssueWorkflowTest.class, NewIssuesMeasureTest.class, // debt + MaintainabilityMeasureTest.class, MaintainabilityRatingMeasureTest.class, + NewDebtRatioMeasureTest.class, + ReliabilityMeasureTest.class, + SecurityMeasureTest.class, TechnicalDebtInIssueChangelogTest.class, - MaintainabilityMeasureTest.class, + TechnicalDebtMeasureVariationTest.class, TechnicalDebtTest.class, TechnicalDebtWidgetTest.class }) diff --git a/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java b/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java index 2aaa892d144..38b7c016c2f 100644 --- a/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java +++ b/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java @@ -76,9 +76,9 @@ public class PurgeTest { collector.checkThat("Wrong number of files", count("projects where qualifier in ('FIL')"), equalTo(4)); collector.checkThat("Wrong number of unit test files", count("projects where qualifier in ('UTS')"), equalTo(0)); - int measuresOnTrk = 46; - int measuresOnBrc = 228; - int measuresOnDir = 145; + int measuresOnTrk = 44; + int measuresOnBrc = 216; + int measuresOnDir = 137; int measuresOnFil = 69; // count measures @@ -105,8 +105,8 @@ public class PurgeTest { // must be a different date, else a single snapshot is kept per day scan(PROJECT_SAMPLE_PATH, DateFormatUtils.ISO_DATE_FORMAT.format(today)); - int newMeasuresOnTrk = 56; - int newMeasuresOnBrc = 292; + int newMeasuresOnTrk = 54; + int newMeasuresOnBrc = 280; int newMeasuresOnDir = 44; int newMeasuresOnFil = 0; diff --git a/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java b/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java index 01bb6359be0..ae4f6a9e7e7 100644 --- a/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java +++ b/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java @@ -21,7 +21,7 @@ package it.qualityModel; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.locator.FileLocation; -import it.Category1Suite; +import it.Category2Suite; import java.util.List; import javax.annotation.Nullable; import org.junit.AfterClass; @@ -46,7 +46,7 @@ public class NewDebtRatioMeasureTest { private static final String NEW_DEBT_RATIO_METRIC_KEY = "new_sqale_debt_ratio"; @ClassRule - public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; @BeforeClass public static void initPeriods() throws Exception { diff --git a/it/it-tests/src/test/java/it/qualityModel/ReliabilityMeasureTest.java b/it/it-tests/src/test/java/it/qualityModel/ReliabilityMeasureTest.java index c04376cc9c0..a54cc223583 100644 --- a/it/it-tests/src/test/java/it/qualityModel/ReliabilityMeasureTest.java +++ b/it/it-tests/src/test/java/it/qualityModel/ReliabilityMeasureTest.java @@ -45,7 +45,6 @@ public class ReliabilityMeasureTest { private static final String BUGS_METRIC = "bugs"; private static final String RELIABILITY_REMEDIATION_EFFORT_METRIC = "reliability_remediation_effort"; private static final String RELIABILITY_RATING_METRIC = "reliability_rating"; - private static final String EFFORT_TO_REACH_RELIABILITY_RATING_A_METRIC = "effort_to_reach_reliability_rating_a"; @ClassRule public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; @@ -66,27 +65,22 @@ public class ReliabilityMeasureTest { assertThat(getMeasure(PROJECT, BUGS_METRIC).getIntValue()).isEqualTo(61); assertThat(getMeasure(PROJECT, RELIABILITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(305); assertThat(getMeasure(PROJECT, RELIABILITY_RATING_METRIC).getData()).isEqualTo("D"); - assertThat(getMeasure(PROJECT, EFFORT_TO_REACH_RELIABILITY_RATING_A_METRIC).getIntValue()).isEqualTo(305); assertThat(getMeasure(MODULE, BUGS_METRIC).getIntValue()).isEqualTo(37); assertThat(getMeasure(MODULE, RELIABILITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(185); assertThat(getMeasure(MODULE, RELIABILITY_RATING_METRIC).getData()).isEqualTo("D"); - assertThat(getMeasure(MODULE, EFFORT_TO_REACH_RELIABILITY_RATING_A_METRIC).getIntValue()).isEqualTo(185); assertThat(getMeasure(SUB_MODULE, BUGS_METRIC).getIntValue()).isEqualTo(16); assertThat(getMeasure(SUB_MODULE, RELIABILITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(80); assertThat(getMeasure(SUB_MODULE, RELIABILITY_RATING_METRIC).getData()).isEqualTo("D"); - assertThat(getMeasure(SUB_MODULE, EFFORT_TO_REACH_RELIABILITY_RATING_A_METRIC).getIntValue()).isEqualTo(80); assertThat(getMeasure(DIRECTORY, BUGS_METRIC).getIntValue()).isEqualTo(16); assertThat(getMeasure(DIRECTORY, RELIABILITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(80); assertThat(getMeasure(DIRECTORY, RELIABILITY_RATING_METRIC).getData()).isEqualTo("D"); - assertThat(getMeasure(DIRECTORY, EFFORT_TO_REACH_RELIABILITY_RATING_A_METRIC).getIntValue()).isEqualTo(80); assertThat(getMeasure(FILE, BUGS_METRIC).getIntValue()).isEqualTo(16); assertThat(getMeasure(FILE, RELIABILITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(80); assertThat(getMeasure(FILE, RELIABILITY_RATING_METRIC).getData()).isEqualTo("D"); - assertThat(getMeasure(FILE, EFFORT_TO_REACH_RELIABILITY_RATING_A_METRIC).getIntValue()).isEqualTo(80); } @Test @@ -98,7 +92,6 @@ public class ReliabilityMeasureTest { assertThat(getMeasure(PROJECT, BUGS_METRIC).getIntValue()).isEqualTo(0); assertThat(getMeasure(PROJECT, RELIABILITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(0); assertThat(getMeasure(PROJECT, RELIABILITY_RATING_METRIC).getData()).isEqualTo("A"); - assertThat(getMeasure(PROJECT, EFFORT_TO_REACH_RELIABILITY_RATING_A_METRIC).getIntValue()).isEqualTo(0); } @CheckForNull diff --git a/it/it-tests/src/test/java/it/qualityModel/SecurityMeasureTest.java b/it/it-tests/src/test/java/it/qualityModel/SecurityMeasureTest.java index 4aeda0ae762..6caf217bd47 100644 --- a/it/it-tests/src/test/java/it/qualityModel/SecurityMeasureTest.java +++ b/it/it-tests/src/test/java/it/qualityModel/SecurityMeasureTest.java @@ -45,7 +45,6 @@ public class SecurityMeasureTest { private static final String VULNERABILITIES_METRIC = "vulnerabilities"; private static final String SECURITY_REMEDIATION_EFFORT_METRIC = "security_remediation_effort"; private static final String SECURITY_RATING_METRIC = "security_rating"; - private static final String EFFORT_TO_REACH_SECURITY_RATING_A_METRIC = "effort_to_reach_security_rating_a"; @ClassRule public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; @@ -66,27 +65,22 @@ public class SecurityMeasureTest { assertThat(getMeasure(PROJECT, VULNERABILITIES_METRIC).getIntValue()).isEqualTo(4); assertThat(getMeasure(PROJECT, SECURITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(340); assertThat(getMeasure(PROJECT, SECURITY_RATING_METRIC).getData()).isEqualTo("E"); - assertThat(getMeasure(PROJECT, EFFORT_TO_REACH_SECURITY_RATING_A_METRIC).getIntValue()).isEqualTo(340); assertThat(getMeasure(MODULE, VULNERABILITIES_METRIC).getIntValue()).isEqualTo(2); assertThat(getMeasure(MODULE, SECURITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(170); assertThat(getMeasure(MODULE, SECURITY_RATING_METRIC).getData()).isEqualTo("E"); - assertThat(getMeasure(MODULE, EFFORT_TO_REACH_SECURITY_RATING_A_METRIC).getIntValue()).isEqualTo(170); assertThat(getMeasure(SUB_MODULE, VULNERABILITIES_METRIC).getIntValue()).isEqualTo(1); assertThat(getMeasure(SUB_MODULE, SECURITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(85); assertThat(getMeasure(SUB_MODULE, SECURITY_RATING_METRIC).getData()).isEqualTo("E"); - assertThat(getMeasure(SUB_MODULE, EFFORT_TO_REACH_SECURITY_RATING_A_METRIC).getIntValue()).isEqualTo(85); assertThat(getMeasure(DIRECTORY, VULNERABILITIES_METRIC).getIntValue()).isEqualTo(0); assertThat(getMeasure(DIRECTORY, SECURITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(0); assertThat(getMeasure(DIRECTORY, SECURITY_RATING_METRIC).getData()).isEqualTo("A"); - assertThat(getMeasure(DIRECTORY, EFFORT_TO_REACH_SECURITY_RATING_A_METRIC).getIntValue()).isEqualTo(0); assertThat(getMeasure(FILE, VULNERABILITIES_METRIC)).isNull(); assertThat(getMeasure(FILE, SECURITY_REMEDIATION_EFFORT_METRIC)).isNull(); assertThat(getMeasure(FILE, SECURITY_RATING_METRIC).getData()).isEqualTo("A"); - assertThat(getMeasure(FILE, EFFORT_TO_REACH_SECURITY_RATING_A_METRIC)).isNull(); } @Test @@ -98,7 +92,6 @@ public class SecurityMeasureTest { assertThat(getMeasure(PROJECT, VULNERABILITIES_METRIC).getIntValue()).isEqualTo(0); assertThat(getMeasure(PROJECT, SECURITY_REMEDIATION_EFFORT_METRIC).getIntValue()).isEqualTo(0); assertThat(getMeasure(PROJECT, SECURITY_RATING_METRIC).getData()).isEqualTo("A"); - assertThat(getMeasure(PROJECT, EFFORT_TO_REACH_SECURITY_RATING_A_METRIC).getIntValue()).isEqualTo(0); } @CheckForNull diff --git a/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtMeasureVariationTest.java b/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtMeasureVariationTest.java index 12b52584144..5980edcfa97 100644 --- a/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtMeasureVariationTest.java +++ b/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtMeasureVariationTest.java @@ -21,7 +21,7 @@ package it.qualityModel; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.locator.FileLocation; -import it.Category1Suite; +import it.Category2Suite; import java.util.List; import org.junit.AfterClass; import org.junit.Before; @@ -42,7 +42,7 @@ import static util.ItUtils.setServerProperty; public class TechnicalDebtMeasureVariationTest { @ClassRule - public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; @BeforeClass public static void initPeriods() throws Exception { diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitor.java index 747a2a108d2..1aa60869226 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitor.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitor.java @@ -38,8 +38,6 @@ import org.sonar.server.computation.qualitymodel.RatingGrid.Rating; import static org.sonar.api.measures.CoreMetrics.DEVELOPMENT_COST_KEY; import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_SECURITY_RATING_A_KEY; import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY; import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING_KEY; import static org.sonar.api.measures.CoreMetrics.SECURITY_RATING_KEY; @@ -62,9 +60,7 @@ import static org.sonar.server.computation.measure.Measure.newMeasureBuilder; * {@link CoreMetrics#SQALE_RATING_KEY} * {@link CoreMetrics#EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY} * {@link CoreMetrics#RELIABILITY_RATING_KEY} - * {@link CoreMetrics#EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY} * {@link CoreMetrics#SECURITY_RATING_KEY} - * {@link CoreMetrics#EFFORT_TO_REACH_SECURITY_RATING_A_KEY} */ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<QualityModelMeasuresVisitor.QualityModelCounter> { private static final Logger LOG = Loggers.get(QualityModelMeasuresVisitor.class); @@ -82,9 +78,7 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality private final Metric maintainabilityRatingMetric; private final Metric effortToMaintainabilityRatingAMetric; private final Metric reliabilityRatingMetric; - private final Metric effortToReliabilityRatingAMetric; private final Metric securityRatingMetric; - private final Metric effortToSecurityRatingAMetric; public QualityModelMeasuresVisitor(MetricRepository metricRepository, MeasureRepository measureRepository, RatingSettings ratingSettings, ComponentIssuesRepository componentIssuesRepository) { @@ -105,8 +99,6 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality this.reliabilityRatingMetric = metricRepository.getByKey(RELIABILITY_RATING_KEY); this.securityRatingMetric = metricRepository.getByKey(SECURITY_RATING_KEY); this.effortToMaintainabilityRatingAMetric = metricRepository.getByKey(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY); - this.effortToReliabilityRatingAMetric = metricRepository.getByKey(EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY); - this.effortToSecurityRatingAMetric = metricRepository.getByKey(EFFORT_TO_REACH_SECURITY_RATING_A_KEY); } @Override @@ -166,14 +158,6 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality if (securityRatingMeasure.isPresent()) { path.parent().addSecurityRating(Rating.valueOf(securityRatingMeasure.get().getData())); } - Optional<Measure> effortToReliabilityRatingAMeasure = measureRepository.getRawMeasure(projectView, effortToReliabilityRatingAMetric); - if (effortToReliabilityRatingAMeasure.isPresent()) { - path.parent().addEffortToReachReliabilityRatingA(effortToReliabilityRatingAMeasure.get().getLongValue()); - } - Optional<Measure> effortToSecurityRatingAMeasure = measureRepository.getRawMeasure(projectView, effortToSecurityRatingAMetric); - if (effortToSecurityRatingAMeasure.isPresent()) { - path.parent().addEffortToReachSecurityRatingA(effortToSecurityRatingAMeasure.get().getLongValue()); - } } private void computeAndSaveMeasures(Component component, Path<QualityModelCounter> path) { @@ -185,14 +169,12 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality addMaintainabilityRatingMeasure(component, density); addEffortToMaintainabilityRatingAMeasure(component, path); addReliabilityRatingMeasure(component, path); - addEffortToReliabilityRatingAMeasure(component, path); addSecurityRatingMeasure(component, path); - addEffortToSecurityRatingAMeasure(component, path); addToParent(path); } - private void addIssues(Component component, Path<QualityModelCounter> path){ + private void addIssues(Component component, Path<QualityModelCounter> path) { for (Issue issue : componentIssuesRepository.getIssues(component)) { if (issue.resolution() == null) { path.current().addIssue(issue); @@ -242,14 +224,6 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality measureRepository.add(component, effortToMaintainabilityRatingAMetric, Measure.newMeasureBuilder().create(effortToRatingA)); } - private void addEffortToReliabilityRatingAMeasure(Component component, Path<QualityModelCounter> path) { - measureRepository.add(component, effortToReliabilityRatingAMetric, Measure.newMeasureBuilder().create(path.current().effortToReachReliabilityRatingA)); - } - - private void addEffortToSecurityRatingAMeasure(Component component, Path<QualityModelCounter> path) { - measureRepository.add(component, effortToSecurityRatingAMetric, Measure.newMeasureBuilder().create(path.current().effortToReachSecurityRatingA)); - } - private static void addToParent(Path<QualityModelCounter> path) { if (!path.isRoot()) { path.parent().add(path.current()); @@ -259,9 +233,7 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality public static final class QualityModelCounter { private long devCosts = 0; private Rating reliabilityRating = Rating.A; - private long effortToReachReliabilityRatingA = 0L; private Rating securityRating = Rating.A; - private long effortToReachSecurityRatingA = 0L; private QualityModelCounter() { // prevents instantiation @@ -271,8 +243,6 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality addDevCosts(otherCounter.devCosts); addReliabilityRating(otherCounter.reliabilityRating); addSecurityRating(otherCounter.securityRating); - addEffortToReachReliabilityRatingA(otherCounter.effortToReachReliabilityRatingA); - addEffortToReachSecurityRatingA(otherCounter.effortToReachSecurityRatingA); } public void addDevCosts(long developmentCosts) { @@ -283,10 +253,8 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality Rating rating = getRatingFromSeverity(issue.severity()); if (issue.type().equals(BUG)) { addReliabilityRating(rating); - addEffortToReachReliabilityRatingA(getEffortForNotMinorIssue(issue)); } else if (issue.type().equals(VULNERABILITY)) { addSecurityRating(rating); - addEffortToReachSecurityRatingA(getEffortForNotMinorIssue(issue)); } } @@ -302,14 +270,6 @@ public class QualityModelMeasuresVisitor extends PathAwareVisitorAdapter<Quality } } - public void addEffortToReachReliabilityRatingA(long reliabilityEffort) { - this.effortToReachReliabilityRatingA += reliabilityEffort; - } - - public void addEffortToReachSecurityRatingA(long securityEffort) { - this.effortToReachSecurityRatingA += securityEffort; - } - private static long getEffortForNotMinorIssue(Issue issue) { Duration effort = issue.effort(); if (!issue.severity().equals(Severity.INFO) && effort != null) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java index e1e22885d52..de06f1c3335 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java @@ -47,7 +47,7 @@ public final class GlobalDefaultDashboard extends DashboardTemplate { public Dashboard createDashboard() { Dashboard dashboard = Dashboard.create() .setGlobal(true) - .setLayout(DashboardLayout.TWO_COLUMNS); + .setLayout(DashboardLayout.TWO_COLUMNS_30_70); dashboard.addWidget(WelcomeWidget.ID, 1); addMyFavouritesWidget(dashboard); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/template/ProjectFilter.java b/server/sonar-server/src/main/java/org/sonar/server/measure/template/ProjectFilter.java index 4b79a70f665..e352b8b754d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/template/ProjectFilter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/template/ProjectFilter.java @@ -42,15 +42,15 @@ public class ProjectFilter extends FilterTemplate { @Override public Filter createFilter() { return Filter.create() - .setDisplayAs(Filter.LIST) - .add(Criterion.createForQualifier(Qualifiers.PROJECT)) - .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("name", null, FilterColumn.ASC, false)) - .add(FilterColumn.create("version", null, FilterColumn.DESC, false)) - .add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("metric", CoreMetrics.CODE_SMELLS_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("metric", CoreMetrics.BUGS_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("metric", CoreMetrics.VULNERABILITIES_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("date", null, FilterColumn.DESC, false)); + .setDisplayAs(Filter.LIST) + .add(Criterion.createForQualifier(Qualifiers.PROJECT)) + .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("name", null, FilterColumn.ASC, false)) + .add(FilterColumn.create("version", null, FilterColumn.DESC, false)) + .add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("metric", CoreMetrics.BUGS_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("metric", CoreMetrics.VULNERABILITIES_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("metric", CoreMetrics.CODE_SMELLS_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("date", null, FilterColumn.DESC, false)); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForReportTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForReportTest.java index eca599624c9..0b2dee0df96 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForReportTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForReportTest.java @@ -47,10 +47,6 @@ import static org.sonar.api.measures.CoreMetrics.DEVELOPMENT_COST; import static org.sonar.api.measures.CoreMetrics.DEVELOPMENT_COST_KEY; import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_MAINTAINABILITY_RATING_A; import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_RELIABILITY_RATING_A; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_SECURITY_RATING_A; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_SECURITY_RATING_A_KEY; import static org.sonar.api.measures.CoreMetrics.NCLOC; import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY; import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING; @@ -108,10 +104,10 @@ public class QualityModelMeasuresVisitorForReportTest { builder(DIRECTORY, DIRECTORY_REF).setKey("directory") .addChildren( builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file1").build(), - builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file2").build() - ).build() - ).build() - ).build(); + builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file2").build()) + .build()) + .build()) + .build(); @Rule public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule(); @@ -125,9 +121,7 @@ public class QualityModelMeasuresVisitorForReportTest { .add(SQALE_RATING) .add(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A) .add(RELIABILITY_RATING) - .add(EFFORT_TO_REACH_RELIABILITY_RATING_A) - .add(SECURITY_RATING) - .add(EFFORT_TO_REACH_SECURITY_RATING_A); + .add(SECURITY_RATING); @Rule public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository); @@ -168,10 +162,7 @@ public class QualityModelMeasuresVisitorForReportTest { entryOf(SQALE_RATING_KEY, createMaintainabilityRatingMeasure(A)), entryOf(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY, newMeasureBuilder().create(0L)), entryOf(RELIABILITY_RATING_KEY, createMaintainabilityRatingMeasure(A)), - entryOf(EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, newMeasureBuilder().create(0L)), - entryOf(SECURITY_RATING_KEY, createMaintainabilityRatingMeasure(A)), - entryOf(EFFORT_TO_REACH_SECURITY_RATING_A_KEY, newMeasureBuilder().create(0L)) - ); + entryOf(SECURITY_RATING_KEY, createMaintainabilityRatingMeasure(A))); } @Test @@ -231,8 +222,7 @@ public class QualityModelMeasuresVisitorForReportTest { // directory has children => dev cost is aggregated verifyAddedRawMeasure(111, DEVELOPMENT_COST_KEY, Long.toString( ncloc1111 * DEV_COST_LANGUAGE_1 + - ncloc1112 * DEV_COST_LANGUAGE_2 - )); + ncloc1112 * DEV_COST_LANGUAGE_2)); verifyAddedRawMeasure(112, DEVELOPMENT_COST_KEY, Long.toString(nclocValue1121 * DEV_COST_LANGUAGE_2)); verifyAddedRawMeasure(121, DEVELOPMENT_COST_KEY, Long.toString(ncloc1211 * DEV_COST_LANGUAGE_1)); @@ -240,16 +230,14 @@ public class QualityModelMeasuresVisitorForReportTest { verifyAddedRawMeasure(11, DEVELOPMENT_COST_KEY, Long.toString( ncloc1111 * DEV_COST_LANGUAGE_1 + ncloc1112 * DEV_COST_LANGUAGE_2 + - nclocValue1121 * DEV_COST_LANGUAGE_2 - )); + nclocValue1121 * DEV_COST_LANGUAGE_2)); verifyAddedRawMeasure(12, DEVELOPMENT_COST_KEY, Long.toString(ncloc1211 * DEV_COST_LANGUAGE_1)); verifyAddedRawMeasure(13, DEVELOPMENT_COST_KEY, "0"); verifyAddedRawMeasure(1, DEVELOPMENT_COST_KEY, Long.toString( ncloc1111 * DEV_COST_LANGUAGE_1 + ncloc1112 * DEV_COST_LANGUAGE_2 + nclocValue1121 * DEV_COST_LANGUAGE_2 + - ncloc1211 * DEV_COST_LANGUAGE_1 - )); + ncloc1211 * DEV_COST_LANGUAGE_1)); } @Test @@ -372,12 +360,10 @@ public class QualityModelMeasuresVisitorForReportTest { treeRootHolder.setRoot(ROOT_PROJECT); fillComponentIssuesVisitorRule.setIssues(FILE_1_REF, newBugIssue(10L, MAJOR), newBugIssue(1L, MAJOR), // Should not be taken into account - newVulnerabilityIssue(5L, MINOR) - ); + newVulnerabilityIssue(5L, MINOR)); fillComponentIssuesVisitorRule.setIssues(FILE_2_REF, newBugIssue(2L, CRITICAL), newBugIssue(3L, MINOR), // Should not be taken into account - newBugIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED) - ); + newBugIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED)); fillComponentIssuesVisitorRule.setIssues(MODULE_REF, newBugIssue(7L, BLOCKER)); underTest.visit(ROOT_PROJECT); @@ -397,8 +383,7 @@ public class QualityModelMeasuresVisitorForReportTest { newBugIssue(1L, MAJOR)); fillComponentIssuesVisitorRule.setIssues(FILE_2_REF, newVulnerabilityIssue(2L, CRITICAL), newVulnerabilityIssue(3L, MINOR), // Should not be taken into account - newVulnerabilityIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED) - ); + newVulnerabilityIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED)); fillComponentIssuesVisitorRule.setIssues(MODULE_REF, newVulnerabilityIssue(7L, BLOCKER)); underTest.visit(ROOT_PROJECT); @@ -475,56 +460,6 @@ public class QualityModelMeasuresVisitorForReportTest { verifyAddedRawMeasure(PROJECT_REF, SECURITY_RATING_KEY, A); } - @Test - public void compute_effort_to_reliability_rating_A_measure() throws Exception { - treeRootHolder.setRoot(ROOT_PROJECT); - - fillComponentIssuesVisitorRule.setIssues(FILE_1_REF, newBugIssue(10L, BLOCKER), newBugIssue(1L, MAJOR), - // CODE SMELL should not be taken into account - newCodeSmellIssue(4L, MAJOR), - // Resolved issue should be ignored - newBugIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED) - ); - fillComponentIssuesVisitorRule.setIssues(FILE_2_REF, newBugIssue(2L, CRITICAL), newBugIssue(3L, MINOR), - // INFO issue should not be taken into account - newBugIssue(5L, INFO), - // Issue without debt - newIssue(MAJOR, BUG)); - - underTest.visit(ROOT_PROJECT); - - verifyAddedRawMeasure(FILE_1_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 10L + 1L); - verifyAddedRawMeasure(FILE_2_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 2L + 3L); - verifyAddedRawMeasure(DIRECTORY_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 16L); - verifyAddedRawMeasure(MODULE_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 16L); - verifyAddedRawMeasure(PROJECT_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 16L); - } - - @Test - public void compute_effort_to_security_rating_A_measure() throws Exception { - treeRootHolder.setRoot(ROOT_PROJECT); - - fillComponentIssuesVisitorRule.setIssues(FILE_1_REF, newVulnerabilityIssue(8L, BLOCKER), newVulnerabilityIssue(6L, MAJOR), - // CODE SMELL should not be taken into account - newCodeSmellIssue(4L, MAJOR), - // Resolved issue should be ignored - newVulnerabilityIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED) - ); - fillComponentIssuesVisitorRule.setIssues(FILE_2_REF, newVulnerabilityIssue(2L, CRITICAL), newVulnerabilityIssue(1L, MINOR), - // INFO issue should not be taken into account - newVulnerabilityIssue(5L, INFO), - // Issue without debt - newIssue(MAJOR, VULNERABILITY)); - - underTest.visit(ROOT_PROJECT); - - verifyAddedRawMeasure(FILE_1_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 8L + 6L); - verifyAddedRawMeasure(FILE_2_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 2L + 1L); - verifyAddedRawMeasure(DIRECTORY_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 17L); - verifyAddedRawMeasure(MODULE_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 17L); - verifyAddedRawMeasure(PROJECT_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 17L); - } - private void addRawMeasure(String metricKey, int componentRef, long value) { measureRepository.addRawMeasure(componentRef, metricKey, newMeasureBuilder().create(value)); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForViewsTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForViewsTest.java index 25bf2b51bdc..b137625fa64 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForViewsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/qualitymodel/QualityModelMeasuresVisitorForViewsTest.java @@ -40,10 +40,6 @@ import static org.sonar.api.measures.CoreMetrics.DEVELOPMENT_COST; import static org.sonar.api.measures.CoreMetrics.DEVELOPMENT_COST_KEY; import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_MAINTAINABILITY_RATING_A; import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_RELIABILITY_RATING_A; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_SECURITY_RATING_A; -import static org.sonar.api.measures.CoreMetrics.EFFORT_TO_REACH_SECURITY_RATING_A_KEY; import static org.sonar.api.measures.CoreMetrics.NCLOC; import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING; import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING_KEY; @@ -109,9 +105,7 @@ public class QualityModelMeasuresVisitorForViewsTest { .add(SQALE_RATING) .add(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A) .add(RELIABILITY_RATING) - .add(EFFORT_TO_REACH_RELIABILITY_RATING_A) - .add(SECURITY_RATING) - .add(EFFORT_TO_REACH_SECURITY_RATING_A); + .add(SECURITY_RATING); @Rule public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository); @@ -126,7 +120,8 @@ public class QualityModelMeasuresVisitorForViewsTest { @Before public void setUp() { when(ratingSettings.getRatingGrid()).thenReturn(new RatingGrid(RATING_GRID)); - underTest = new VisitorsCrawler(Arrays.<ComponentVisitor>asList(new QualityModelMeasuresVisitor(metricRepository, measureRepository, ratingSettings, componentIssuesRepositoryRule))); + underTest = new VisitorsCrawler( + Arrays.<ComponentVisitor>asList(new QualityModelMeasuresVisitor(metricRepository, measureRepository, ratingSettings, componentIssuesRepositoryRule))); } @Test @@ -143,10 +138,7 @@ public class QualityModelMeasuresVisitorForViewsTest { entryOf(SQALE_RATING_KEY, createMaintainabilityRatingMeasure(A)), entryOf(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY, newMeasureBuilder().create(0L)), entryOf(RELIABILITY_RATING_KEY, createMaintainabilityRatingMeasure(A)), - entryOf(EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, newMeasureBuilder().create(0L)), - entryOf(SECURITY_RATING_KEY, createMaintainabilityRatingMeasure(A)), - entryOf(EFFORT_TO_REACH_SECURITY_RATING_A_KEY, newMeasureBuilder().create(0L)) - ); + entryOf(SECURITY_RATING_KEY, createMaintainabilityRatingMeasure(A))); } @Test @@ -244,40 +236,6 @@ public class QualityModelMeasuresVisitorForViewsTest { projectView4DevCosts))); } - @Test - public void compute_effort_to_reliability_rating_A_measure() throws Exception { - treeRootHolder.setRoot(treeRootHolder.getRoot()); - - addRawMeasure(EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, PROJECT_VIEW_1_REF, 100L); - addRawMeasure(EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, PROJECT_VIEW_2_REF, 200L); - addRawMeasure(EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, PROJECT_VIEW_3_REF, 300L); - // Nothing on project view 4 - - underTest.visit(treeRootHolder.getRoot()); - - verifyRawMeasure(SUB_SUBVIEW_1_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 100L + 200L); - verifyRawMeasure(SUB_SUBVIEW_2_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 300L); - verifyRawMeasure(SUBVIEW_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 600L); - verifyRawMeasure(ROOT_REF, EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, 600L); - } - - @Test - public void compute_effort_to_security_rating_A_measure() throws Exception { - treeRootHolder.setRoot(treeRootHolder.getRoot()); - - addRawMeasure(EFFORT_TO_REACH_SECURITY_RATING_A_KEY, PROJECT_VIEW_1_REF, 100L); - addRawMeasure(EFFORT_TO_REACH_SECURITY_RATING_A_KEY, PROJECT_VIEW_2_REF, 200L); - addRawMeasure(EFFORT_TO_REACH_SECURITY_RATING_A_KEY, PROJECT_VIEW_3_REF, 300L); - addRawMeasure(EFFORT_TO_REACH_SECURITY_RATING_A_KEY, PROJECT_VIEW_4_REF, 50L); - - underTest.visit(treeRootHolder.getRoot()); - - verifyRawMeasure(SUB_SUBVIEW_1_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 100L + 200L); - verifyRawMeasure(SUB_SUBVIEW_2_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 300L); - verifyRawMeasure(SUBVIEW_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 600L); - verifyRawMeasure(ROOT_REF, EFFORT_TO_REACH_SECURITY_RATING_A_KEY, 650L); - } - private void assertNewRawMeasures(int componentRef, long debt, long devCost, Rating rating) { assertThat(toEntries(measureRepository.getAddedRawMeasures(componentRef))).contains( entryOf(DEVELOPMENT_COST_KEY, newMeasureBuilder().create(String.valueOf(devCost))), @@ -300,10 +258,6 @@ public class QualityModelMeasuresVisitorForViewsTest { measureRepository.addRawMeasure(componentRef, metricKey, newMeasureBuilder().create(value)); } - private void addRawMeasure(String metricKey, int componentRef, int value) { - measureRepository.addRawMeasure(componentRef, metricKey, newMeasureBuilder().create(value)); - } - private void addRawMeasure(String metricKey, int componentRef, Rating value) { measureRepository.addRawMeasure(componentRef, metricKey, newMeasureBuilder().create(value.getIndex(), value.name())); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index 496df500e5f..9d201c6a401 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -2346,23 +2346,6 @@ public final class CoreMetrics { .setWorstValue(5.0) .create(); - /** - * @since 5.5 - */ - public static final String EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY = "effort_to_reach_reliability_rating_a"; - - /** - * @since 5.5 - */ - public static final Metric<Long> EFFORT_TO_REACH_RELIABILITY_RATING_A = new Metric.Builder(EFFORT_TO_REACH_RELIABILITY_RATING_A_KEY, "Effort to reach reliability rating A", - Metric.ValueType.WORK_DUR) - .setDomain(DOMAIN_RELIABILITY) - .setDirection(Metric.DIRECTION_WORST) - .setQualitative(true) - .setBestValue(0.0) - .setOptimizedBestValue(true) - .create(); - // -------------------------------------------------------------------------------------------------------------------- // // SECURITY CHARACTERISTIC @@ -2420,23 +2403,6 @@ public final class CoreMetrics { .setWorstValue(5.0) .create(); - /** - * @since 5.5 - */ - public static final String EFFORT_TO_REACH_SECURITY_RATING_A_KEY = "effort_to_reach_security_rating_a"; - - /** - * @since 5.5 - */ - public static final Metric<Long> EFFORT_TO_REACH_SECURITY_RATING_A = new Metric.Builder(EFFORT_TO_REACH_SECURITY_RATING_A_KEY, "Effort to reach security rating A", - Metric.ValueType.WORK_DUR) - .setDomain(DOMAIN_SECURITY) - .setDirection(Metric.DIRECTION_WORST) - .setQualitative(true) - .setBestValue(0.0) - .setOptimizedBestValue(true) - .create(); - // -------------------------------------------------------------------------------------------------------------------- // // FILE DATA |