aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-10-26 13:35:39 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-10-26 13:35:39 +0200
commit936985bf5e2a2c14ceb68ae291995c6a5d76d2c0 (patch)
tree78a35e9bf12adf3f0d13085be5314bf5baa4cfa1
parent331558e106bc9bda51dfa39cc9a5874aa62c236c (diff)
downloadsonarqube-936985bf5e2a2c14ceb68ae291995c6a5d76d2c0.tar.gz
sonarqube-936985bf5e2a2c14ceb68ae291995c6a5d76d2c0.zip
Fix quality flaws
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitor.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ComponentCleanerServiceTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForReportTest.java9
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForViewsTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java2
-rw-r--r--server/sonar-web/src/main/js/apps/projects/store/actions.js2
8 files changed, 10 insertions, 32 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java
index 92e3c0a46e8..b74f1228357 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java
@@ -31,7 +31,6 @@ import org.sonar.db.MyBatis;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.component.es.ProjectMeasuresIndexer;
import org.sonar.server.issue.index.IssueIndexer;
-import org.sonar.server.permission.index.PermissionIndexer;
import org.sonar.server.test.index.TestIndexer;
@ServerSide
@@ -39,17 +38,15 @@ import org.sonar.server.test.index.TestIndexer;
public class ComponentCleanerService {
private final DbClient dbClient;
- private final PermissionIndexer permissionIndexer;
private final IssueIndexer issueIndexer;
private final TestIndexer testIndexer;
private final ProjectMeasuresIndexer projectMeasuresIndexer;
private final ResourceTypes resourceTypes;
private final ComponentFinder componentFinder;
- public ComponentCleanerService(DbClient dbClient, PermissionIndexer permissionIndexer, IssueIndexer issueIndexer,
- TestIndexer testIndexer, ProjectMeasuresIndexer projectMeasuresIndexer, ResourceTypes resourceTypes, ComponentFinder componentFinder) {
+ public ComponentCleanerService(DbClient dbClient, IssueIndexer issueIndexer, TestIndexer testIndexer, ProjectMeasuresIndexer projectMeasuresIndexer, ResourceTypes resourceTypes,
+ ComponentFinder componentFinder) {
this.dbClient = dbClient;
- this.permissionIndexer = permissionIndexer;
this.issueIndexer = issueIndexer;
this.testIndexer = testIndexer;
this.projectMeasuresIndexer = projectMeasuresIndexer;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitor.java
index 3b4b9877b12..43057b08f93 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitor.java
@@ -33,7 +33,6 @@ import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepository;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING_KEY;
import static org.sonar.api.measures.CoreMetrics.SECURITY_RATING_KEY;
@@ -71,7 +70,6 @@ public class ReliabilityAndSecurityRatingMeasuresVisitor extends PathAwareVisito
private final MeasureRepository measureRepository;
private final ComponentIssuesRepository componentIssuesRepository;
- private final PeriodsHolder periodsHolder;
// Output metrics
private final Metric reliabilityRatingMetric;
@@ -79,12 +77,10 @@ public class ReliabilityAndSecurityRatingMeasuresVisitor extends PathAwareVisito
private final Map<String, Metric> metricsByKey;
- public ReliabilityAndSecurityRatingMeasuresVisitor(MetricRepository metricRepository, MeasureRepository measureRepository, ComponentIssuesRepository componentIssuesRepository,
- PeriodsHolder periodsHolder) {
+ public ReliabilityAndSecurityRatingMeasuresVisitor(MetricRepository metricRepository, MeasureRepository measureRepository, ComponentIssuesRepository componentIssuesRepository) {
super(LEAVES, POST_ORDER, CounterFactory.INSTANCE);
this.measureRepository = measureRepository;
this.componentIssuesRepository = componentIssuesRepository;
- this.periodsHolder = periodsHolder;
// Output metrics
this.reliabilityRatingMetric = metricRepository.getByKey(RELIABILITY_RATING_KEY);
@@ -147,7 +143,7 @@ public class ReliabilityAndSecurityRatingMeasuresVisitor extends PathAwareVisito
.stream()
.filter(issue -> issue.resolution() == null)
.filter(issue -> issue.type().equals(BUG) || issue.type().equals(VULNERABILITY))
- .forEach(issue -> path.current().processIssue(issue));
+ .forEach(path.current()::processIssue);
}
private static void addToParent(Path<Counter> path) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentCleanerServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentCleanerServiceTest.java
index abdf7a01435..3a1a7d2f35c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentCleanerServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentCleanerServiceTest.java
@@ -83,9 +83,7 @@ public class ComponentCleanerServiceTest {
ResourceTypes mockResourceTypes = mock(ResourceTypes.class);
- ComponentCleanerService underTest = new ComponentCleanerService(dbClient,
- permissionIndexer, issueIndexer, testIndexer, projectMeasuresIndexer,
- mockResourceTypes,
+ ComponentCleanerService underTest = new ComponentCleanerService(dbClient, issueIndexer, testIndexer, projectMeasuresIndexer, mockResourceTypes,
new ComponentFinder(dbClient));
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForReportTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForReportTest.java
index 417cbbe9e77..7f69d94b10b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForReportTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForReportTest.java
@@ -38,8 +38,6 @@ import org.sonar.server.computation.task.projectanalysis.issue.FillComponentIssu
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
-import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
@@ -104,16 +102,13 @@ public class ReliabilityAndSecurityRatingMeasuresVisitorForReportTest {
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule().setPeriods(new Period(1, "mode", null, 12323l, "UUID"));
-
- @Rule
public ComponentIssuesRepositoryRule componentIssuesRepositoryRule = new ComponentIssuesRepositoryRule(treeRootHolder);
@Rule
public FillComponentIssuesVisitorRule fillComponentIssuesVisitorRule = new FillComponentIssuesVisitorRule(componentIssuesRepositoryRule, treeRootHolder);
- VisitorsCrawler underTest = new VisitorsCrawler(Arrays.asList(fillComponentIssuesVisitorRule,
- new ReliabilityAndSecurityRatingMeasuresVisitor(metricRepository, measureRepository, componentIssuesRepositoryRule, periodsHolder)));
+ VisitorsCrawler underTest = new VisitorsCrawler(
+ Arrays.asList(fillComponentIssuesVisitorRule, new ReliabilityAndSecurityRatingMeasuresVisitor(metricRepository, measureRepository, componentIssuesRepositoryRule)));
@Test
public void measures_created_for_project_are_all_A_when_they_have_no_FILE_child() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForViewsTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForViewsTest.java
index c4c4b8b8abe..905cd528922 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForViewsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorForViewsTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.computation.task.projectanalysis.qualitymodel;
-import java.util.Arrays;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
@@ -29,9 +28,9 @@ import org.sonar.server.computation.task.projectanalysis.issue.ComponentIssuesRe
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
import org.sonar.server.computation.task.projectanalysis.qualitymodel.RatingGrid.Rating;
+import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING;
import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING_KEY;
@@ -89,13 +88,10 @@ public class ReliabilityAndSecurityRatingMeasuresVisitorForViewsTest {
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
-
- @Rule
public ComponentIssuesRepositoryRule componentIssuesRepositoryRule = new ComponentIssuesRepositoryRule(treeRootHolder);
VisitorsCrawler underTest = new VisitorsCrawler(
- Arrays.asList(new ReliabilityAndSecurityRatingMeasuresVisitor(metricRepository, measureRepository, componentIssuesRepositoryRule, periodsHolder)));
+ singletonList(new ReliabilityAndSecurityRatingMeasuresVisitor(metricRepository, measureRepository, componentIssuesRepositoryRule)));
@Test
public void measures_created_for_view_are_all_zero_when_no_child() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
index 95a5b0d5d24..65fc6fc7fd5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
@@ -51,7 +51,6 @@ import org.sonar.server.issue.IssueTesting;
import org.sonar.server.issue.index.IssueAuthorizationDoc;
import org.sonar.server.issue.index.IssueIndexDefinition;
import org.sonar.server.issue.index.IssueIndexer;
-import org.sonar.server.permission.index.PermissionIndexer;
import org.sonar.server.test.index.TestDoc;
import org.sonar.server.test.index.TestIndexDefinition;
import org.sonar.server.test.index.TestIndexer;
@@ -98,7 +97,6 @@ public class BulkDeleteActionTest {
ws = new WsTester(new ProjectsWs(
new BulkDeleteAction(
new ComponentCleanerService(dbClient,
- new PermissionIndexer(dbClient, es.client()),
new IssueIndexer(dbClient, es.client()),
new TestIndexer(dbClient, es.client()),
new ProjectMeasuresIndexer(dbClient, es.client()),
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
index bbeca990d7e..bed24ac4e3a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
@@ -49,7 +49,6 @@ import org.sonar.server.issue.IssueTesting;
import org.sonar.server.issue.index.IssueAuthorizationDoc;
import org.sonar.server.issue.index.IssueIndexDefinition;
import org.sonar.server.issue.index.IssueIndexer;
-import org.sonar.server.permission.index.PermissionIndexer;
import org.sonar.server.test.index.TestDoc;
import org.sonar.server.test.index.TestIndexDefinition;
import org.sonar.server.test.index.TestIndexer;
@@ -100,7 +99,6 @@ public class DeleteActionTest {
new DeleteAction(
new ComponentCleanerService(
dbClient,
- new PermissionIndexer(dbClient, es.client()),
new IssueIndexer(dbClient, es.client()),
new TestIndexer(dbClient, es.client()),
new ProjectMeasuresIndexer(dbClient, es.client()),
diff --git a/server/sonar-web/src/main/js/apps/projects/store/actions.js b/server/sonar-web/src/main/js/apps/projects/store/actions.js
index a3437217d0b..5e1a29453b3 100644
--- a/server/sonar-web/src/main/js/apps/projects/store/actions.js
+++ b/server/sonar-web/src/main/js/apps/projects/store/actions.js
@@ -48,7 +48,7 @@ const onFail = dispatch => error => {
dispatch(updateState({ loading: false }));
};
-const onReceiveMeasures = (dispatch, projects) => response => {
+const onReceiveMeasures = dispatch => response => {
const byComponentKey = groupBy(response.measures, 'component');
const toStore = {};