From b0c0624706cdaf22a6d4c966ad69693e13430e74 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 8 Oct 2014 11:35:55 +0200 Subject: [PATCH] Fix some quality flaws --- .../scan/filesystem/InputFileBuilderFactory.java | 11 +---------- .../batch/scan2/DefaultFileLinesContextFactory.java | 3 +-- .../org/sonar/batch/scan2/ModuleScanContainer.java | 2 +- .../org/sonar/batch/scan2/ModuleScanExecutor.java | 3 +-- .../scan/filesystem/InputFileBuilderFactoryTest.java | 5 +---- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java index 772f773cb5f..59f1e667edd 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java @@ -21,7 +21,6 @@ package org.sonar.batch.scan.filesystem; import org.sonar.api.BatchComponent; import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.PathResolver; import org.sonar.batch.bootstrap.AnalysisMode; @@ -33,17 +32,9 @@ public class InputFileBuilderFactory implements BatchComponent { private final StatusDetectionFactory statusDetectionFactory; private final AnalysisMode analysisMode; - public InputFileBuilderFactory(Project module, ProjectDefinition def, PathResolver pathResolver, LanguageDetectionFactory langDetectionFactory, - StatusDetectionFactory statusDetectionFactory, AnalysisMode analysisMode) { - this(module.getEffectiveKey(), pathResolver, langDetectionFactory, statusDetectionFactory, analysisMode); - } - - /** - * Used by scan2 - */ public InputFileBuilderFactory(ProjectDefinition def, PathResolver pathResolver, LanguageDetectionFactory langDetectionFactory, StatusDetectionFactory statusDetectionFactory, AnalysisMode analysisMode) { - this(def.getKey(), pathResolver, langDetectionFactory, statusDetectionFactory, analysisMode); + this(def.getKeyWithBranch(), pathResolver, langDetectionFactory, statusDetectionFactory, analysisMode); } private InputFileBuilderFactory(String effectiveKey, PathResolver pathResolver, LanguageDetectionFactory langDetectionFactory, diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java index 603cf47bb3f..8805ac83d89 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java @@ -20,7 +20,6 @@ package org.sonar.batch.scan2; import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.measure.MetricFinder; import org.sonar.api.measures.FileLinesContext; @@ -35,7 +34,7 @@ public class DefaultFileLinesContextFactory implements FileLinesContextFactory { private final ProjectDefinition def; private InputPathCache fileCache; - public DefaultFileLinesContextFactory(InputPathCache fileCache, FileSystem fs, MetricFinder metricFinder, AnalyzerMeasureCache measureCache, + public DefaultFileLinesContextFactory(InputPathCache fileCache, MetricFinder metricFinder, AnalyzerMeasureCache measureCache, ProjectDefinition def) { this.fileCache = fileCache; this.metricFinder = metricFinder; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java index 67e2a37908d..41a2cda0390 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java @@ -139,7 +139,7 @@ public class ModuleScanContainer extends ComponentContainer { @Override protected void doAfterStart() { - getComponentByType(ModuleScanExecutor.class).execute(moduleDefinition); + getComponentByType(ModuleScanExecutor.class).execute(); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java index 8611bd3b26a..088125818df 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java @@ -20,7 +20,6 @@ package org.sonar.batch.scan2; import com.google.common.collect.Lists; -import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader; import org.sonar.batch.rule.QProfileVerifier; @@ -60,7 +59,7 @@ public final class ModuleScanExecutor { /** * Executed on each module */ - public void execute(ProjectDefinition moduleDefinition) { + public void execute() { fsLogger.log(); // Index and lock the filesystem diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java index e38081b62be..bb78a170c84 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java @@ -22,7 +22,6 @@ package org.sonar.batch.scan.filesystem; import org.junit.Test; import org.mockito.Mockito; import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.PathResolver; import org.sonar.batch.bootstrap.AnalysisMode; @@ -33,14 +32,12 @@ public class InputFileBuilderFactoryTest { @Test public void create_builder() throws Exception { PathResolver pathResolver = new PathResolver(); - Project project = new Project("struts"); LanguageDetectionFactory langDetectionFactory = mock(LanguageDetectionFactory.class, Mockito.RETURNS_MOCKS); StatusDetectionFactory statusDetectionFactory = mock(StatusDetectionFactory.class, Mockito.RETURNS_MOCKS); DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class); AnalysisMode analysisMode = mock(AnalysisMode.class); - InputFileBuilderFactory factory = new InputFileBuilderFactory( - project, ProjectDefinition.create(), pathResolver, langDetectionFactory, + InputFileBuilderFactory factory = new InputFileBuilderFactory(ProjectDefinition.create().setKey("struts"), pathResolver, langDetectionFactory, statusDetectionFactory, analysisMode); InputFileBuilder builder = factory.create(fs); -- 2.39.5