]> source.dussan.org Git - sonarqube.git/commitdiff
Clean container
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 20 Sep 2017 13:48:06 +0000 (15:48 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 28 Sep 2017 07:14:43 +0000 (09:14 +0200)
14 files changed:
sonar-scanner-engine/src/main/java/org/sonar/scanner/DefaultFileLinesContextFactory.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProvider.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetection.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactory.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProviderTest.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactoryTest.java [deleted file]

index d7fe982fcc600e00b8071c5bb1634885d9bd692b..b5206fa9fb597d9bc33ea0cd8e61390b49a0be4b 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.scanner;
 
+import javax.annotation.concurrent.Immutable;
 import org.sonar.api.batch.SensorContext;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.measure.MetricFinder;
@@ -26,6 +27,7 @@ import org.sonar.api.measures.FileLinesContext;
 import org.sonar.api.measures.FileLinesContextFactory;
 import org.sonar.scanner.scan.measure.MeasureCache;
 
+@Immutable
 public class DefaultFileLinesContextFactory implements FileLinesContextFactory {
 
   private final SensorContext sensorContext;
index a36dbcef2c0d97e9c9e9fdb51900732fab9125e6..0c1af1a91d7925251bcefdc10b4c2383de2ee3b8 100644 (file)
@@ -188,9 +188,8 @@ public class ComponentsPublisher implements ReportPublisherStep {
     return false;
   }
 
-  private static void writeVersion(DefaultInputModule module, ScannerReport.Component.Builder builder) {
-    ProjectDefinition def = module.definition();
-    String version = getVersion(def);
+  private void writeVersion(DefaultInputModule module, ScannerReport.Component.Builder builder) {
+    String version = getVersion(module);
     if (version != null) {
       builder.setVersion(version);
     }
@@ -215,13 +214,15 @@ public class ComponentsPublisher implements ReportPublisherStep {
     throw new IllegalStateException("Unkown component: " + component.getClass());
   }
 
-  private static String getVersion(ProjectDefinition def) {
-    String version = def.getOriginalVersion();
+  private String getVersion(DefaultInputModule module) {
+    String version = module.getOriginalVersion();
     if (StringUtils.isNotBlank(version)) {
       return version;
     }
 
-    return def.getParent() != null ? getVersion(def.getParent()) : null;
+    DefaultInputModule parent = moduleHierarchy.parent(module);
+
+    return parent != null ? getVersion(parent) : null;
   }
 
   private static void writeLinks(InputComponent c, ScannerReport.Component.Builder builder) {
index c66213ffbd3558f92fc46bebaad07e7c581e0a8e..0a1caea08215422ab3611f48a4c7d8f286d6454e 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.scanner.report;
 
 import java.util.Map.Entry;
 import java.util.Optional;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
 import org.sonar.api.config.Configuration;
@@ -62,11 +61,10 @@ public class MetadataPublisher implements ReportPublisherStep {
   @Override
   public void publish(ScannerReportWriter writer) {
     DefaultInputModule rootProject = moduleHierarchy.root();
-    ProjectDefinition rootDef = rootProject.definition();
     ScannerReport.Metadata.Builder builder = ScannerReport.Metadata.newBuilder()
       .setAnalysisDate(projectAnalysisInfo.analysisDate().getTime())
       // Here we want key without branch
-      .setProjectKey(rootDef.getKey())
+      .setProjectKey(rootProject.key())
       .setCrossProjectDuplicationActivated(cpdSettings.isCrossProjectDuplicationEnabled())
       .setRootComponentRef(rootProject.batchId());
 
@@ -80,7 +78,7 @@ public class MetadataPublisher implements ReportPublisherStep {
         builder.setMergeBranchName(branchTarget);
       }
     }
-    Optional.ofNullable(rootDef.getBranch()).ifPresent(builder::setDeprecatedBranch);
+    Optional.ofNullable(rootProject.getBranch()).ifPresent(builder::setDeprecatedBranch);
 
     for (QProfile qp : qProfiles.findAll()) {
       builder.getMutableQprofilesPerLanguage().put(qp.getLanguage(), ScannerReport.Metadata.QProfile.newBuilder()
index 14e403f2a01e3d15c3ec734029f65a27b4bbe9ef..1628dc97d52ede89308d76a2856c38612cf6046e 100644 (file)
@@ -21,18 +21,19 @@ package org.sonar.scanner.scan;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.InstantiationStrategy;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.FileMetadata;
 import org.sonar.api.batch.fs.internal.SensorStrategy;
 import org.sonar.api.batch.rule.CheckFactory;
+import org.sonar.api.issue.NoSonarFilter;
 import org.sonar.api.resources.Project;
 import org.sonar.api.scan.filesystem.FileExclusions;
 import org.sonar.core.platform.ComponentContainer;
 import org.sonar.scanner.DefaultFileLinesContextFactory;
 import org.sonar.scanner.bootstrap.ExtensionInstaller;
 import org.sonar.scanner.bootstrap.ExtensionUtils;
+import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
 import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;
 import org.sonar.scanner.deprecated.DeprecatedSensorContext;
 import org.sonar.scanner.deprecated.perspectives.ScannerPerspectives;
@@ -64,10 +65,9 @@ import org.sonar.scanner.scan.filesystem.ExclusionFilters;
 import org.sonar.scanner.scan.filesystem.FileIndexer;
 import org.sonar.scanner.scan.filesystem.InputFileBuilder;
 import org.sonar.scanner.scan.filesystem.LanguageDetection;
-import org.sonar.scanner.scan.filesystem.MetadataGeneratorProvider;
+import org.sonar.scanner.scan.filesystem.MetadataGenerator;
 import org.sonar.scanner.scan.filesystem.ModuleFileSystemInitializer;
 import org.sonar.scanner.scan.filesystem.ModuleInputComponentStore;
-import org.sonar.scanner.scan.filesystem.StatusDetectionFactory;
 import org.sonar.scanner.scan.report.IssuesReports;
 import org.sonar.scanner.sensor.DefaultSensorStorage;
 import org.sonar.scanner.sensor.SensorOptimizer;
@@ -77,10 +77,12 @@ import org.sonar.scanner.source.SymbolizableBuilder;
 public class ModuleScanContainer extends ComponentContainer {
   private static final Logger LOG = LoggerFactory.getLogger(ModuleScanContainer.class);
   private final DefaultInputModule module;
+  private final GlobalAnalysisMode analysisMode;
 
-  public ModuleScanContainer(ProjectScanContainer parent, DefaultInputModule module) {
+  public ModuleScanContainer(ProjectScanContainer parent, DefaultInputModule module, GlobalAnalysisMode analysisMode) {
     super(parent);
     this.module = module;
+    this.analysisMode = analysisMode;
   }
 
   @Override
@@ -99,11 +101,13 @@ public class ModuleScanContainer extends ComponentContainer {
       MutableModuleSettings.class,
       new ModuleSettingsProvider());
 
-    if (getComponentByType(AnalysisMode.class).isIssues()) {
-      add(IssuesPhaseExecutor.class,
+    if (analysisMode.isIssues()) {
+      add(
+        IssuesPhaseExecutor.class,
         IssuesReports.class);
     } else {
-      add(PublishPhaseExecutor.class);
+      add(
+        PublishPhaseExecutor.class);
     }
 
     add(
@@ -117,7 +121,7 @@ public class ModuleScanContainer extends ComponentContainer {
       ModuleInputComponentStore.class,
       FileExclusions.class,
       ExclusionFilters.class,
-      new MetadataGeneratorProvider(),
+      MetadataGenerator.class,
       FileMetadata.class,
       LanguageDetection.class,
       FileIndexer.class,
@@ -145,7 +149,7 @@ public class ModuleScanContainer extends ComponentContainer {
       // issues
       IssuableFactory.class,
       ModuleIssues.class,
-      org.sonar.api.issue.NoSonarFilter.class,
+      NoSonarFilter.class,
 
       // issue exclusions
       IssueInclusionPatternInitializer.class,
index fc34c441582d3b0fa6665b00487a5cea3c949a28..053f750158d628c534287281e1d3537a98fc9841 100644 (file)
@@ -93,7 +93,7 @@ import org.sonar.scanner.scan.branch.BranchType;
 import org.sonar.scanner.scan.branch.ProjectBranchesProvider;
 import org.sonar.scanner.scan.filesystem.BatchIdGenerator;
 import org.sonar.scanner.scan.filesystem.InputComponentStoreProvider;
-import org.sonar.scanner.scan.filesystem.StatusDetectionFactory;
+import org.sonar.scanner.scan.filesystem.StatusDetection;
 import org.sonar.scanner.scan.measure.DefaultMetricFinder;
 import org.sonar.scanner.scan.measure.DeprecatedMetricFinder;
 import org.sonar.scanner.scan.measure.MeasureCache;
@@ -160,7 +160,7 @@ public class ProjectScanContainer extends ComponentContainer {
       DefaultComponentTree.class,
       BatchIdGenerator.class,
       new ScmChangedFilesProvider(),
-      StatusDetectionFactory.class,
+      StatusDetection.class,
 
       // rules
       new ActiveRulesProvider(),
@@ -256,7 +256,7 @@ public class ProjectScanContainer extends ComponentContainer {
     }
 
     LOG.debug("Start recursive analysis of project modules");
-    scanRecursively(tree, tree.root());
+    scanRecursively(tree, tree.root(), analysisMode);
 
     if (analysisMode.isMediumTest()) {
       getComponentByType(ScanTaskObservers.class).notifyEndOfScanTask();
@@ -274,16 +274,16 @@ public class ProjectScanContainer extends ComponentContainer {
     }
   }
 
-  private void scanRecursively(InputModuleHierarchy tree, DefaultInputModule module) {
+  private void scanRecursively(InputModuleHierarchy tree, DefaultInputModule module, GlobalAnalysisMode analysisMode) {
     for (DefaultInputModule child : tree.children(module)) {
-      scanRecursively(tree, child);
+      scanRecursively(tree, child, analysisMode);
     }
-    scan(module);
+    scan(module, analysisMode);
   }
 
   @VisibleForTesting
-  void scan(DefaultInputModule module) {
-    new ModuleScanContainer(this, module).execute();
+  void scan(DefaultInputModule module, GlobalAnalysisMode analysisMode) {
+    new ModuleScanContainer(this, module, analysisMode).execute();
   }
 
   static class BatchExtensionFilter implements ExtensionMatcher {
index 3ad3c9960ad38a4d2cadf94b2e4eb8b23e13926f..c57c1aba573a29071b6865530d1b0e684c609d65 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.api.batch.fs.internal.FileMetadata;
 import org.sonar.api.batch.fs.internal.Metadata;
 import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader;
 
-class MetadataGenerator {
+public class MetadataGenerator {
   private static final Logger LOG = LoggerFactory.getLogger(MetadataGenerator.class);
   @VisibleForTesting
   static final Charset UTF_32BE = Charset.forName("UTF-32BE");
@@ -44,7 +44,7 @@ class MetadataGenerator {
   private final DefaultInputModule inputModule;
   private final IssueExclusionsLoader exclusionsScanner;
 
-  MetadataGenerator(DefaultInputModule inputModule, StatusDetection statusDetection, FileMetadata fileMetadata, IssueExclusionsLoader exclusionsScanner) {
+  public MetadataGenerator(DefaultInputModule inputModule, StatusDetection statusDetection, FileMetadata fileMetadata, IssueExclusionsLoader exclusionsScanner) {
     this.inputModule = inputModule;
     this.statusDetection = statusDetection;
     this.fileMetadata = fileMetadata;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProvider.java
deleted file mode 100644 (file)
index 4e935f1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.scan.filesystem;
-
-import org.picocontainer.injectors.ProviderAdapter;
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.batch.fs.internal.DefaultInputModule;
-import org.sonar.api.batch.fs.internal.FileMetadata;
-import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader;
-
-@ScannerSide
-public class MetadataGeneratorProvider extends ProviderAdapter {
-  public MetadataGenerator provide(DefaultInputModule inputModule, StatusDetectionFactory statusDetectionFactory, FileMetadata fileMetadata,
-    IssueExclusionsLoader exclusionsScanner) {
-    return new MetadataGenerator(inputModule, statusDetectionFactory.create(), fileMetadata, exclusionsScanner);
-  }
-}
index 8a3c2893dc69ad88287094d8cd6d0bdd22c82a45..634428629e0477010a02d952800f979881a2a24a 100644 (file)
@@ -50,31 +50,31 @@ public class ModuleFileSystemInitializer {
   private final List<Path> testDirsOrFiles;
   private final Charset encoding;
 
-  public ModuleFileSystemInitializer(DefaultInputModule inputModule, ProjectDefinition module) {
+  public ModuleFileSystemInitializer(DefaultInputModule inputModule) {
     logDir("Base dir: ", inputModule.getBaseDir());
     logDir("Working dir: ", inputModule.getWorkDir());
-    sourceDirsOrFiles = initSources(module, inputModule.getBaseDir(), ProjectDefinition.SOURCES_PROPERTY, "Source paths: ");
-    testDirsOrFiles = initSources(module, inputModule.getBaseDir(), ProjectDefinition.TESTS_PROPERTY, "Test paths: ");
-    encoding = initEncoding(module);
+    sourceDirsOrFiles = initSources(inputModule, ProjectDefinition.SOURCES_PROPERTY, "Source paths: ");
+    testDirsOrFiles = initSources(inputModule, ProjectDefinition.TESTS_PROPERTY, "Test paths: ");
+    encoding = initEncoding(inputModule);
   }
 
-  private static List<Path> initSources(ProjectDefinition module, Path baseDir, String propertyKey, String logLabel) {
+  private static List<Path> initSources(DefaultInputModule module, String propertyKey, String logLabel) {
     List<Path> result = new ArrayList<>();
     PathResolver pathResolver = new PathResolver();
     String srcPropValue = module.properties().get(propertyKey);
     if (srcPropValue != null) {
       for (String sourcePath : parseAsCsv(propertyKey, srcPropValue)) {
-        File dirOrFile = pathResolver.relativeFile(module.getBaseDir(), sourcePath);
+        File dirOrFile = pathResolver.relativeFile(module.getBaseDir().toFile(), sourcePath);
         if (dirOrFile.exists()) {
           result.add(dirOrFile.toPath());
         }
       }
     }
-    logPaths(logLabel, baseDir, result);
+    logPaths(logLabel, module.getBaseDir(), result);
     return result;
   }
 
-  private static Charset initEncoding(ProjectDefinition module) {
+  private static Charset initEncoding(DefaultInputModule module) {
     String encodingStr = module.properties().get(CoreProperties.ENCODING_PROPERTY);
     Charset result;
     if (StringUtils.isNotEmpty(encodingStr)) {
index b91a8165734aee185c2f697cfeda64526dd0bdbe..8ba900e3f6535963af584fe3235bfcb94a597d82 100644 (file)
@@ -28,12 +28,12 @@ import org.sonar.scanner.repository.ProjectRepositories;
 import org.sonar.scanner.scm.ScmChangedFiles;
 
 @Immutable
-class StatusDetection {
+public class StatusDetection {
 
   private final ProjectRepositories projectRepositories;
   private final ScmChangedFiles scmChangedFiles;
 
-  StatusDetection(ProjectRepositories projectSettings, ScmChangedFiles scmChangedFiles) {
+  public StatusDetection(ProjectRepositories projectSettings, ScmChangedFiles scmChangedFiles) {
     this.projectRepositories = projectSettings;
     this.scmChangedFiles = scmChangedFiles;
   }
@@ -50,7 +50,7 @@ class StatusDetection {
     if (StringUtils.isEmpty(previousHash)) {
       return InputFile.Status.ADDED;
     }
-    if (!scmChangedFiles.confirmChanged(inputFile.path())) {
+    if (!scmChangedFiles.verifyChanged(inputFile.path())) {
       return InputFile.Status.SAME;
     }
     return InputFile.Status.CHANGED;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactory.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactory.java
deleted file mode 100644 (file)
index b1cdf61..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.scan.filesystem;
-
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.scm.ScmChangedFiles;
-
-@ScannerSide
-public class StatusDetectionFactory {
-
-  private final ProjectRepositories projectReferentials;
-  private final ScmChangedFiles scmChangedFiles;
-
-  public StatusDetectionFactory(ProjectRepositories projectReferentials, ScmChangedFiles scmChangedFiles) {
-    this.projectReferentials = projectReferentials;
-    this.scmChangedFiles = scmChangedFiles;
-  }
-
-  StatusDetection create() {
-    return new StatusDetection(projectReferentials, scmChangedFiles);
-  }
-}
index 5ebfeb7e8526c89f3ef6d7081e19daa9af5efccb..528aa5b968c6782f5c612fb08fb6e13ae8f7a387 100644 (file)
@@ -104,6 +104,7 @@ public class ComponentsPublisherTest {
     moduleHierarchy = mock(InputModuleHierarchy.class);
     when(moduleHierarchy.root()).thenReturn(root);
     when(moduleHierarchy.children(root)).thenReturn(Collections.singleton(module1));
+    when(moduleHierarchy.parent(module1)).thenReturn(root);
     tree.index(module1, root);
 
     DefaultInputDir dir = new DefaultInputDir("module1", "src", 3);
@@ -471,6 +472,7 @@ public class ComponentsPublisherTest {
     moduleHierarchy = mock(InputModuleHierarchy.class);
     when(moduleHierarchy.root()).thenReturn(root);
     when(moduleHierarchy.children(root)).thenReturn(Collections.singleton(module1));
+    when(moduleHierarchy.parent(module1)).thenReturn(root);
     tree.index(module1, root);
 
     DefaultInputDir dir = new DefaultInputDir("module1", "src", 3);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProviderTest.java
deleted file mode 100644 (file)
index 5ebded1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.scan.filesystem;
-
-import java.io.IOException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.mockito.Mockito;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.fs.internal.DefaultInputModule;
-import org.sonar.api.batch.fs.internal.FileMetadata;
-import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer;
-import org.sonar.scanner.issue.ignore.pattern.PatternMatcher;
-import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-public class MetadataGeneratorProviderTest {
-
-  @Rule
-  public TemporaryFolder temp = new TemporaryFolder();
-
-  @Test
-  public void create_builder() throws IOException {
-    StatusDetectionFactory statusDetectionFactory = mock(StatusDetectionFactory.class, Mockito.RETURNS_MOCKS);
-    IssueExclusionsLoader issueExclusionsLoader = new IssueExclusionsLoader(mock(IssueExclusionPatternInitializer.class), mock(PatternMatcher.class));
-
-    MetadataGeneratorProvider factory = new MetadataGeneratorProvider();
-    assertThat(factory.provide(new DefaultInputModule(ProjectDefinition.create().setKey("module").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder())),
-      statusDetectionFactory, new FileMetadata(), issueExclusionsLoader)).isNotNull();
-  }
-}
index 0d915fb747fa2f3995e8d767265804bce4ef26b2..c0173ebf09f77eb2f0e3a5c2f8c0dbaeba3eca75 100644 (file)
@@ -48,7 +48,7 @@ public class ModuleFileSystemInitializerTest {
     File workDir = temp.newFolder("work");
     ProjectDefinition module = ProjectDefinition.create().setBaseDir(baseDir).setWorkDir(workDir);
 
-    ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(new DefaultInputModule(module), module);
+    ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(new DefaultInputModule(module));
 
     assertThat(logTester.logs(LoggerLevel.INFO)).contains("Base dir: " + baseDir.toPath().toAbsolutePath().toString());
     assertThat(logTester.logs(LoggerLevel.INFO)).contains("Working dir: " + workDir.toPath().toAbsolutePath().toString());
@@ -73,7 +73,7 @@ public class ModuleFileSystemInitializerTest {
       .addSources("src/main/java", "src/main/unknown")
       .addTests("src/test/java", "src/test/unknown");
 
-    ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(new DefaultInputModule(project), project);
+    ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(new DefaultInputModule(project));
 
     assertThat(initializer.sources()).hasSize(1);
     assertThat(path(initializer.sources().get(0))).endsWith("src/main/java");
@@ -96,7 +96,7 @@ public class ModuleFileSystemInitializerTest {
       .addSources("\"my,File.cs\"")
       .addTests("\"my,TestFile.cs\"");
 
-    ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(new DefaultInputModule(project), project);
+    ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(new DefaultInputModule(project));
 
     assertThat(initializer.sources()).hasSize(1);
     assertThat(initializer.sources().get(0)).isEqualTo(sourceFile.toPath());
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactoryTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactoryTest.java
deleted file mode 100644 (file)
index 259b5e5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.scan.filesystem;
-
-import org.junit.Test;
-import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.scm.ScmChangedFiles;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-public class StatusDetectionFactoryTest {
-  @Test
-  public void testCreate() throws Exception {
-    StatusDetectionFactory factory = new StatusDetectionFactory(mock(ProjectRepositories.class), mock(ScmChangedFiles.class));
-    StatusDetection detection = factory.create();
-    assertThat(detection).isNotNull();
-  }
-}