aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-09-20 15:48:06 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2017-09-28 09:14:43 +0200
commit0a201a057cac9263b641614d5491d2061ab3ab80 (patch)
tree89106407f5351214a4259e8f1c9a4f3f20bd474c /sonar-scanner-engine/src
parente19f3f56fe2d8bc2101086b166ec4de92a5c3c8f (diff)
downloadsonarqube-0a201a057cac9263b641614d5491d2061ab3ab80.tar.gz
sonarqube-0a201a057cac9263b641614d5491d2061ab3ab80.zip
Clean container
Diffstat (limited to 'sonar-scanner-engine/src')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/DefaultFileLinesContextFactory.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java13
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java22
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java16
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProvider.java34
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java16
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetection.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactory.java40
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProviderTest.java51
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializerTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactoryTest.java36
14 files changed, 50 insertions, 204 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/DefaultFileLinesContextFactory.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/DefaultFileLinesContextFactory.java
index d7fe982fcc6..b5206fa9fb5 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/DefaultFileLinesContextFactory.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/DefaultFileLinesContextFactory.java
@@ -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;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
index a36dbcef2c0..0c1af1a91d7 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
@@ -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) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
index c66213ffbd3..0a1caea0821 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
@@ -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()
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
index 14e403f2a01..1628dc97d52 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
@@ -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,
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index fc34c441582..053f750158d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -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 {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java
index 3ad3c9960ad..c57c1aba573 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java
@@ -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
index 4e935f1905e..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProvider.java
+++ /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);
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java
index 8a3c2893dc6..634428629e0 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializer.java
@@ -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)) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetection.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetection.java
index b91a8165734..8ba900e3f65 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetection.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetection.java
@@ -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
index b1cdf614e6b..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactory.java
+++ /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);
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
index 5ebfeb7e852..528aa5b968c 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
@@ -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
index 5ebded1daec..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorProviderTest.java
+++ /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();
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializerTest.java
index 0d915fb747f..c0173ebf09f 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleFileSystemInitializerTest.java
@@ -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
index 259b5e5a653..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactoryTest.java
+++ /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();
- }
-}