aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStep.java111
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java1
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStepTest.java160
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisWarningsStepTest.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java37
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java19
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java29
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java9
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java47
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/SourcePublisherTest.java3
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java3
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleIndexerTest.java3
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java87
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java3
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java33
-rw-r--r--sonar-scanner-protocol/src/main/protobuf/scanner_report.proto2
18 files changed, 76 insertions, 499 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStep.java
deleted file mode 100644
index 217aeafe712..00000000000
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStep.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.ce.task.projectanalysis.step;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.stream.Collectors;
-import org.sonar.api.utils.System2;
-import org.sonar.ce.task.log.CeTaskMessages;
-import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
-import org.sonar.ce.task.step.ComputationStep;
-import org.sonar.core.platform.EditionProvider;
-import org.sonar.core.platform.PlatformEditionProvider;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.String.format;
-
-/**
- * Check if there are files that could be analyzed with a higher SQ edition.
- */
-public class PerformNotAnalyzedFilesCheckStep implements ComputationStep {
- static final String DESCRIPTION = "Check upgrade possibility for not analyzed code files.";
-
- private static final String LANGUAGE_UPGRADE_MESSAGE = "%s file(s) detected during the last analysis. %s code cannot be analyzed with SonarQube " +
- "community edition. Please consider <a href=\"https://www.sonarqube.org/trial-request/developer-edition/?referrer=sonarqube-cpp\">upgrading to " +
- "the Developer Edition</a> to analyze this language.";
-
- private final BatchReportReader reportReader;
- private final CeTaskMessages ceTaskMessages;
- private final PlatformEditionProvider editionProvider;
- private final System2 system;
-
- public PerformNotAnalyzedFilesCheckStep(BatchReportReader reportReader, CeTaskMessages ceTaskMessages, PlatformEditionProvider editionProvider,
- System2 system) {
- this.reportReader = reportReader;
- this.ceTaskMessages = ceTaskMessages;
- this.editionProvider = editionProvider;
- this.system = system;
- }
-
- @Override
- public void execute(Context context) {
- editionProvider.get().ifPresent(edition -> {
- if (!edition.equals(EditionProvider.Edition.COMMUNITY)) {
- return;
- }
-
- Map<String, Integer> filesPerLanguage = reportReader.readMetadata().getNotAnalyzedFilesByLanguageMap()
- .entrySet()
- .stream()
- .filter(entry -> entry.getValue() > 0)
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
- if (filesPerLanguage.isEmpty()) {
- return;
- }
-
- ceTaskMessages.add(constructMessage(filesPerLanguage));
- });
- }
-
- private CeTaskMessages.Message constructMessage(Map<String, Integer> filesPerLanguage) {
- checkNotNull(filesPerLanguage);
- checkArgument(filesPerLanguage.size() > 0);
-
- SortedMap<String, Integer> sortedLanguageMap = new TreeMap<>(filesPerLanguage);
- Iterator<Map.Entry<String, Integer>> iterator = sortedLanguageMap.entrySet().iterator();
- Map.Entry<String, Integer> firstLanguage = iterator.next();
- StringBuilder languageLabel = new StringBuilder(firstLanguage.getKey());
- StringBuilder fileCountLabel = new StringBuilder(format("%s %s", firstLanguage.getValue(), firstLanguage.getKey()));
- while (iterator.hasNext()) {
- Map.Entry<String, Integer> nextLanguage = iterator.next();
- if (iterator.hasNext()) {
- languageLabel.append(", ");
- fileCountLabel.append(", ");
- } else {
- languageLabel.append(" and ");
- fileCountLabel.append(" and ");
- }
- languageLabel.append(nextLanguage.getKey());
- fileCountLabel.append(format("%s %s", nextLanguage.getValue(), nextLanguage.getKey()));
- }
-
- return new CeTaskMessages.Message(format(LANGUAGE_UPGRADE_MESSAGE, fileCountLabel, languageLabel), system.now());
- }
-
- @Override
- public String getDescription() {
- return DESCRIPTION;
- }
-}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java
index cd708269303..9eda77e3c9a 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java
@@ -38,7 +38,6 @@ public class ReportComputationSteps extends AbstractComputationSteps {
private static final List<Class<? extends ComputationStep>> STEPS = Arrays.asList(
ExtractReportStep.class,
PersistScannerContextStep.class,
- PerformNotAnalyzedFilesCheckStep.class,
PersistAnalysisWarningsStep.class,
GenerateAnalysisUuid.class,
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStepTest.java
deleted file mode 100644
index 130a7a519ed..00000000000
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PerformNotAnalyzedFilesCheckStepTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.ce.task.projectanalysis.step;
-
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import java.util.Optional;
-import org.junit.Rule;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.sonar.api.utils.System2;
-import org.sonar.ce.task.log.CeTaskMessages;
-import org.sonar.ce.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.ce.task.step.TestComputationStepContext;
-import org.sonar.core.platform.EditionProvider;
-import org.sonar.core.platform.PlatformEditionProvider;
-import org.sonar.scanner.protocol.output.ScannerReport;
-
-import static com.google.common.collect.ImmutableList.of;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class PerformNotAnalyzedFilesCheckStepTest {
-
- @Rule
- public BatchReportReaderRule reportReader = new BatchReportReaderRule();
-
- private final PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
- private final CeTaskMessages ceTaskMessages = mock(CeTaskMessages.class);
- private final PerformNotAnalyzedFilesCheckStep underTest = new PerformNotAnalyzedFilesCheckStep(reportReader, ceTaskMessages, editionProvider, System2.INSTANCE);
-
- @Test
- public void getDescription() {
- assertThat(underTest.getDescription()).isEqualTo(PerformNotAnalyzedFilesCheckStep.DESCRIPTION);
- }
-
- @Test
- public void execute_adds_warning_in_SQ_community_edition_if_there_are_c_or_cpp_files() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
- ScannerReport.AnalysisWarning warning1 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 1").build();
- ScannerReport.AnalysisWarning warning2 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 2").build();
- ImmutableList<ScannerReport.AnalysisWarning> warnings = of(warning1, warning2);
- reportReader.setAnalysisWarnings(warnings);
- reportReader.setMetadata(ScannerReport.Metadata.newBuilder()
- .putNotAnalyzedFilesByLanguage("C++", 20)
- .putNotAnalyzedFilesByLanguage("C", 10)
- .putNotAnalyzedFilesByLanguage("SomeLang", 1000)
- .build());
- ArgumentCaptor<CeTaskMessages.Message> argumentCaptor = ArgumentCaptor.forClass(CeTaskMessages.Message.class);
-
- underTest.execute(new TestComputationStepContext());
-
- verify(ceTaskMessages, times(1)).add(argumentCaptor.capture());
- List<CeTaskMessages.Message> messages = argumentCaptor.getAllValues();
- assertThat(messages).extracting(CeTaskMessages.Message::getText).containsExactly(
- "10 C, 20 C++ and 1000 SomeLang file(s) detected during the last analysis. C, C++ and SomeLang code cannot be analyzed with SonarQube community " +
- "edition. Please consider <a href=\"https://www.sonarqube.org/trial-request/developer-edition/?referrer=sonarqube-cpp\">upgrading to the Developer " +
- "Edition</a> to analyze this language.");
- }
-
- @Test
- public void execute_adds_warning_in_SQ_community_edition_if_there_are_c_files() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
- reportReader.setMetadata(ScannerReport.Metadata.newBuilder()
- .putNotAnalyzedFilesByLanguage("C", 10)
- .build());
- ArgumentCaptor<CeTaskMessages.Message> argumentCaptor = ArgumentCaptor.forClass(CeTaskMessages.Message.class);
-
- underTest.execute(new TestComputationStepContext());
-
- verify(ceTaskMessages, times(1)).add(argumentCaptor.capture());
- List<CeTaskMessages.Message> messages = argumentCaptor.getAllValues();
- assertThat(messages).extracting(CeTaskMessages.Message::getText).containsExactly(
- "10 C file(s) detected during the last analysis. C code cannot be analyzed with SonarQube community " +
- "edition. Please consider <a href=\"https://www.sonarqube.org/trial-request/developer-edition/?referrer=sonarqube-cpp\">upgrading to the Developer " +
- "Edition</a> to analyze this language.");
- }
-
- @Test
- public void execute_adds_warning_in_SQ_community_edition_if_there_are_cpp_files() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
- reportReader.setMetadata(ScannerReport.Metadata.newBuilder()
- .putNotAnalyzedFilesByLanguage("C++", 9)
- .build());
- ArgumentCaptor<CeTaskMessages.Message> argumentCaptor = ArgumentCaptor.forClass(CeTaskMessages.Message.class);
-
- underTest.execute(new TestComputationStepContext());
-
- verify(ceTaskMessages, times(1)).add(argumentCaptor.capture());
- List<CeTaskMessages.Message> messages = argumentCaptor.getAllValues();
- assertThat(messages).extracting(CeTaskMessages.Message::getText).containsExactly(
- "9 C++ file(s) detected during the last analysis. C++ code cannot be analyzed with SonarQube community " +
- "edition. Please consider <a href=\"https://www.sonarqube.org/trial-request/developer-edition/?referrer=sonarqube-cpp\">upgrading to the Developer " +
- "Edition</a> to analyze this language.");
- }
-
- @Test
- public void execute_does_not_add_a_warning_in_SQ_community_edition_if_cpp_files_in_report_is_zero() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
- ScannerReport.AnalysisWarning warning1 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 1").build();
- ScannerReport.AnalysisWarning warning2 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 2").build();
- ImmutableList<ScannerReport.AnalysisWarning> warnings = of(warning1, warning2);
- reportReader.setAnalysisWarnings(warnings);
- reportReader.setMetadata(ScannerReport.Metadata.newBuilder().putNotAnalyzedFilesByLanguage("C++", 0).build());
-
- underTest.execute(new TestComputationStepContext());
-
- verify(ceTaskMessages, never()).add(any());
- }
-
- @Test
- public void execute_does_not_add_a_warning_in_SQ_community_edition_if_no_c_or_cpp_files_2() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
- ScannerReport.AnalysisWarning warning1 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 1").build();
- ScannerReport.AnalysisWarning warning2 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 2").build();
- ImmutableList<ScannerReport.AnalysisWarning> warnings = of(warning1, warning2);
- reportReader.setAnalysisWarnings(warnings);
- reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
-
- underTest.execute(new TestComputationStepContext());
-
- verify(ceTaskMessages, never()).add(any());
- }
-
- @Test
- public void execute_does_not_add_a_warning_in_SQ_non_community_edition() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.ENTERPRISE));
- ScannerReport.AnalysisWarning warning1 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 1").build();
- ScannerReport.AnalysisWarning warning2 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 2").build();
- ImmutableList<ScannerReport.AnalysisWarning> warnings = of(warning1, warning2);
- reportReader.setAnalysisWarnings(warnings);
- reportReader.setMetadata(ScannerReport.Metadata.newBuilder().putNotAnalyzedFilesByLanguage("C++", 20).build());
-
- underTest.execute(new TestComputationStepContext());
-
- verify(ceTaskMessages, never()).add(any());
- }
-}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisWarningsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisWarningsStepTest.java
index 1185859da3f..b49c37fe7d1 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisWarningsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisWarningsStepTest.java
@@ -34,7 +34,7 @@ import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.verifyZeroInteractions;
public class PersistAnalysisWarningsStepTest {
@@ -70,6 +70,6 @@ public class PersistAnalysisWarningsStepTest {
underTest.execute(new TestComputationStepContext());
- verifyNoInteractions(ceTaskMessages);
+ verifyZeroInteractions(ceTaskMessages);
}
}
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 67e6ea79269..3eb0ed89517 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
@@ -25,6 +25,7 @@ import java.time.Instant;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.regex.Pattern;
+import javax.annotation.Nullable;
import org.sonar.api.batch.fs.internal.AbstractProjectOrModule;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.scm.ScmProvider;
@@ -43,7 +44,6 @@ import org.sonar.scanner.rule.QProfile;
import org.sonar.scanner.rule.QualityProfiles;
import org.sonar.scanner.scan.ScanProperties;
import org.sonar.scanner.scan.branch.BranchConfiguration;
-import org.sonar.scanner.scan.filesystem.InputComponentStore;
import org.sonar.scanner.scm.ScmConfiguration;
import org.sonar.scanner.scm.ScmRevision;
@@ -60,12 +60,12 @@ public class MetadataPublisher implements ReportPublisherStep {
private final BranchConfiguration branchConfiguration;
private final ScmRevision scmRevision;
private final ForkDateSupplier forkDateSupplier;
- private final InputComponentStore componentStore;
+ @Nullable
private final ScmConfiguration scmConfiguration;
public MetadataPublisher(ProjectInfo projectInfo, InputModuleHierarchy moduleHierarchy, ScanProperties properties,
QualityProfiles qProfiles, CpdSettings cpdSettings, ScannerPluginRepository pluginRepository, BranchConfiguration branchConfiguration,
- ScmRevision scmRevision, ForkDateSupplier forkDateSupplier, InputComponentStore componentStore, ScmConfiguration scmConfiguration) {
+ ScmRevision scmRevision, ForkDateSupplier forkDateSupplier, @Nullable ScmConfiguration scmConfiguration) {
this.projectInfo = projectInfo;
this.moduleHierarchy = moduleHierarchy;
this.properties = properties;
@@ -75,10 +75,14 @@ public class MetadataPublisher implements ReportPublisherStep {
this.branchConfiguration = branchConfiguration;
this.scmRevision = scmRevision;
this.forkDateSupplier = forkDateSupplier;
- this.componentStore = componentStore;
this.scmConfiguration = scmConfiguration;
}
+ public MetadataPublisher(ProjectInfo projectInfo, InputModuleHierarchy moduleHierarchy, ScanProperties properties, QualityProfiles qProfiles,
+ CpdSettings cpdSettings, ScannerPluginRepository pluginRepository, BranchConfiguration branchConfiguration, ScmRevision scmRevision, ForkDateSupplier forkDateSupplier) {
+ this(projectInfo, moduleHierarchy, properties, qProfiles, cpdSettings, pluginRepository, branchConfiguration, scmRevision, forkDateSupplier, null);
+ }
+
@Override
public void publish(ScannerReportWriter writer) {
AbstractProjectOrModule rootProject = moduleHierarchy.root();
@@ -99,7 +103,6 @@ public class MetadataPublisher implements ReportPublisherStep {
addScmInformation(builder);
addForkPoint(builder);
- addNotAnalyzedFileCountsByLanguage(builder);
for (QProfile qp : qProfiles.findAll()) {
builder.putQprofilesPerLanguage(qp.getLanguage(), ScannerReport.Metadata.QProfile.newBuilder()
@@ -139,16 +142,16 @@ public class MetadataPublisher implements ReportPublisherStep {
}
}
- ScmProvider scmProvider = scmConfiguration.provider();
- if (scmProvider == null) {
- return;
- }
-
- Path projectBasedir = moduleHierarchy.root().getBaseDir();
- try {
- builder.setRelativePathFromScmRoot(toSonarQubePath(scmProvider.relativePathFromScmRoot(projectBasedir)));
- } catch (UnsupportedOperationException e) {
- LOG.debug(e.getMessage());
+ if (scmConfiguration != null) {
+ ScmProvider scmProvider = scmConfiguration.provider();
+ if (scmProvider != null) {
+ Path projectBasedir = moduleHierarchy.root().getBaseDir();
+ try {
+ builder.setRelativePathFromScmRoot(toSonarQubePath(scmProvider.relativePathFromScmRoot(projectBasedir)));
+ } catch (UnsupportedOperationException e) {
+ LOG.debug(e.getMessage());
+ }
+ }
}
}
@@ -163,10 +166,6 @@ public class MetadataPublisher implements ReportPublisherStep {
}
}
- private void addNotAnalyzedFileCountsByLanguage(ScannerReport.Metadata.Builder builder) {
- builder.putAllNotAnalyzedFilesByLanguage(componentStore.getNotAnalysedFilesByLanguage());
- }
-
private void addBranchInformation(ScannerReport.Metadata.Builder builder) {
builder.setBranchName(branchConfiguration.branchName());
BranchType branchType = toProtobufBranchType(branchConfiguration.branchType());
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
index ed533e97999..21435f623ad 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
@@ -30,16 +30,16 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFile.Type;
import org.sonar.api.batch.fs.InputFileFilter;
-import org.sonar.api.batch.fs.internal.DefaultIndexedFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputModule;
-import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.batch.fs.internal.SensorStrategy;
import org.sonar.api.batch.scm.IgnoreCommand;
import org.sonar.api.notifications.AnalysisWarnings;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.batch.fs.internal.DefaultIndexedFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputModule;
+import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader;
import org.sonar.scanner.scan.ScanProperties;
import org.sonar.scanner.util.ProgressReport;
@@ -52,7 +52,6 @@ import static java.lang.String.format;
public class FileIndexer {
private static final Logger LOG = Loggers.get(FileIndexer.class);
-
private final AnalysisWarnings analysisWarnings;
private final ScanProperties properties;
private final InputFileFilter[] filters;
@@ -90,11 +89,10 @@ public class FileIndexer {
}
public FileIndexer(DefaultInputProject project, ScannerComponentIdGenerator scannerComponentIdGenerator, InputComponentStore componentStore,
- ProjectExclusionFilters projectExclusionFilters, ProjectCoverageAndDuplicationExclusions projectCoverageAndDuplicationExclusions,
- IssueExclusionsLoader issueExclusionsLoader, MetadataGenerator metadataGenerator, SensorStrategy sensorStrategy,
- LanguageDetection languageDetection, AnalysisWarnings analysisWarnings, ScanProperties properties) {
- this(project, scannerComponentIdGenerator, componentStore, projectExclusionFilters, projectCoverageAndDuplicationExclusions, issueExclusionsLoader,
- metadataGenerator, sensorStrategy, languageDetection, analysisWarnings, properties, new InputFileFilter[0]);
+ ProjectExclusionFilters projectExclusionFilters, ProjectCoverageAndDuplicationExclusions projectCoverageAndDuplicationExclusions, IssueExclusionsLoader issueExclusionsLoader,
+ MetadataGenerator metadataGenerator, SensorStrategy sensorStrategy, LanguageDetection languageDetection, AnalysisWarnings analysisWarnings, ScanProperties properties) {
+ this(project, scannerComponentIdGenerator, componentStore, projectExclusionFilters, projectCoverageAndDuplicationExclusions, issueExclusionsLoader, metadataGenerator,
+ sensorStrategy, languageDetection, analysisWarnings, properties, new InputFileFilter[0]);
}
void indexFile(DefaultInputModule module, ModuleExclusionFilters moduleExclusionFilters, ModuleCoverageAndDuplicationExclusions moduleCoverageAndDuplicationExclusions,
@@ -271,4 +269,5 @@ public class FileIndexer {
private static String pluralizeFiles(int count) {
return count == 1 ? "file" : "files";
}
+
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java
index 1f757db9bbe..627da73d5fe 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java
@@ -19,7 +19,6 @@
*/
package org.sonar.scanner.scan.filesystem;
-import com.google.common.collect.ImmutableMap;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -30,11 +29,8 @@ import java.util.Optional;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.regex.Pattern;
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
-import org.sonar.api.SonarEdition;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
@@ -51,9 +47,6 @@ import static org.sonar.api.utils.Preconditions.checkState;
* exclusion patterns are already applied.
*/
public class InputComponentStore extends DefaultFileSystem.Cache {
- private static final Map<String, Pattern> FILE_PATTERN_BY_LANGUAGE = ImmutableMap.of(
- "C", Pattern.compile(".*\\.c", Pattern.CASE_INSENSITIVE),
- "C++", Pattern.compile(".*\\.cpp|.*\\.cc|.*\\.cxx|.*\\.c\\+\\+", Pattern.CASE_INSENSITIVE));
private final SortedSet<String> globalLanguagesCache = new TreeSet<>();
private final Map<String, SortedSet<String>> languagesCache = new HashMap<>();
@@ -65,12 +58,9 @@ public class InputComponentStore extends DefaultFileSystem.Cache {
private final Map<String, Set<InputFile>> filesByNameCache = new HashMap<>();
private final Map<String, Set<InputFile>> filesByExtensionCache = new HashMap<>();
private final BranchConfiguration branchConfiguration;
- private final SonarRuntime sonarRuntime;
- private final Map<String, Integer> notAnalysedFilesByLanguage = new HashMap<>();
- public InputComponentStore(BranchConfiguration branchConfiguration, SonarRuntime sonarRuntime) {
+ public InputComponentStore(BranchConfiguration branchConfiguration) {
this.branchConfiguration = branchConfiguration;
- this.sonarRuntime = sonarRuntime;
}
public Collection<InputComponent> all() {
@@ -107,8 +97,6 @@ public class InputComponentStore extends DefaultFileSystem.Cache {
public InputComponentStore put(String moduleKey, InputFile inputFile) {
DefaultInputFile file = (DefaultInputFile) inputFile;
- updateNotAnalysedCAndCppFileCount(file);
-
addToLanguageCache(moduleKey, file);
inputFileByModuleCache.computeIfAbsent(moduleKey, x -> new HashMap<>()).put(file.getModuleRelativePath(), inputFile);
inputModuleKeyByFileCache.put(inputFile, moduleKey);
@@ -181,19 +169,4 @@ public class InputComponentStore extends DefaultFileSystem.Cache {
throw new UnsupportedOperationException();
}
- private void updateNotAnalysedCAndCppFileCount(DefaultInputFile inputFile) {
- if (!SonarEdition.COMMUNITY.equals(sonarRuntime.getEdition())) {
- return;
- }
-
- FILE_PATTERN_BY_LANGUAGE.forEach((language, filePattern) -> {
- if (filePattern.matcher(inputFile.filename()).matches()) {
- notAnalysedFilesByLanguage.put(language, notAnalysedFilesByLanguage.getOrDefault(language, 0) + 1);
- }
- });
- }
-
- public Map<String, Integer> getNotAnalysedFilesByLanguage() {
- return ImmutableMap.copyOf(notAnalysedFilesByLanguage);
- }
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
index e33909d47fb..5f4da8fae26 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
@@ -64,7 +64,7 @@ public class ProjectFileIndexer {
private static final Logger LOG = Loggers.get(ProjectFileIndexer.class);
private final ProjectExclusionFilters projectExclusionFilters;
private final ProjectCoverageAndDuplicationExclusions projectCoverageAndDuplicationExclusions;
- private final ScmConfiguration scmConfiguration;
+ private ScmConfiguration scmConfiguration;
private final InputComponentStore componentStore;
private final InputModuleHierarchy inputModuleHierarchy;
private final GlobalConfiguration globalConfig;
@@ -189,15 +189,14 @@ public class ProjectFileIndexer {
return count == 1 ? "file" : "files";
}
- private void indexFiles(DefaultInputModule module, ModuleExclusionFilters moduleExclusionFilters,
- ModuleCoverageAndDuplicationExclusions moduleCoverageAndDuplicationExclusions, List<Path> sources, Type type, ExclusionCounter exclusionCounter) {
+ private void indexFiles(DefaultInputModule module, ModuleExclusionFilters moduleExclusionFilters, ModuleCoverageAndDuplicationExclusions moduleCoverageAndDuplicationExclusions,
+ List<Path> sources, Type type, ExclusionCounter exclusionCounter) {
try {
for (Path dirOrFile : sources) {
if (dirOrFile.toFile().isDirectory()) {
indexDirectory(module, moduleExclusionFilters, moduleCoverageAndDuplicationExclusions, dirOrFile, type, exclusionCounter);
} else {
- fileIndexer.indexFile(module, moduleExclusionFilters, moduleCoverageAndDuplicationExclusions, dirOrFile, type, progressReport, exclusionCounter,
- ignoreCommand);
+ fileIndexer.indexFile(module, moduleExclusionFilters, moduleCoverageAndDuplicationExclusions, dirOrFile, type, progressReport, exclusionCounter, ignoreCommand);
}
}
} catch (IOException e) {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
index f8614ce4fcc..7598a64e485 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
@@ -36,7 +36,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.mockito.ArgumentMatchers;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.core.util.CloseableIterator;
@@ -73,11 +72,10 @@ public class CpdExecutorTest {
public ExpectedException thrown = ExpectedException.none();
private CpdExecutor executor;
- private final ExecutorService executorService = mock(ExecutorService.class);
- private final CpdSettings settings = mock(CpdSettings.class);
- private final ReportPublisher publisher = mock(ReportPublisher.class);
- private final SonarRuntime sonarRuntime = mock(SonarRuntime.class);
- private final SonarCpdBlockIndex index = new SonarCpdBlockIndex(publisher, settings);
+ private ExecutorService executorService = mock(ExecutorService.class);
+ private CpdSettings settings = mock(CpdSettings.class);
+ private ReportPublisher publisher = mock(ReportPublisher.class);
+ private SonarCpdBlockIndex index = new SonarCpdBlockIndex(publisher, settings);
private ScannerReportReader reader;
private DefaultInputFile batchComponent1;
private DefaultInputFile batchComponent2;
@@ -92,7 +90,7 @@ public class CpdExecutorTest {
when(publisher.getWriter()).thenReturn(new ScannerReportWriter(outputDir));
DefaultInputProject project = TestInputFileBuilder.newDefaultInputProject("foo", baseDir);
- componentStore = new InputComponentStore(mock(BranchConfiguration.class), sonarRuntime);
+ componentStore = new InputComponentStore(mock(BranchConfiguration.class));
executor = new CpdExecutor(settings, index, publisher, componentStore, executorService);
reader = new ScannerReportReader(outputDir);
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 74bc606295f..c1458524e51 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
@@ -27,7 +27,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFile.Type;
@@ -50,9 +49,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ComponentsPublisherTest {
-
- private final SonarRuntime sonarRuntime = mock(SonarRuntime.class);
-
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@@ -81,7 +77,7 @@ public class ComponentsPublisherTest {
.setWorkDir(temp.newFolder());
DefaultInputProject project = new DefaultInputProject(rootDef, 1);
- InputComponentStore store = new InputComponentStore(branchConfiguration, sonarRuntime);
+ InputComponentStore store = new InputComponentStore(branchConfiguration);
Path moduleBaseDir = temp.newFolder().toPath();
ProjectDefinition module1Def = ProjectDefinition.create()
@@ -147,7 +143,7 @@ public class ComponentsPublisherTest {
.setWorkDir(temp.newFolder());
DefaultInputProject project = new DefaultInputProject(rootDef, 1);
- InputComponentStore store = new InputComponentStore(branchConfiguration, sonarRuntime);
+ InputComponentStore store = new InputComponentStore(branchConfiguration);
DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.java", 5)
.setLines(2)
@@ -184,7 +180,7 @@ public class ComponentsPublisherTest {
.setWorkDir(temp.newFolder());
DefaultInputProject project = new DefaultInputProject(rootDef, 1);
- InputComponentStore store = new InputComponentStore(branchConfiguration, sonarRuntime);
+ InputComponentStore store = new InputComponentStore(branchConfiguration);
ComponentsPublisher publisher = new ComponentsPublisher(project, store);
publisher.publish(writer);
@@ -214,7 +210,7 @@ public class ComponentsPublisherTest {
.setWorkDir(temp.newFolder());
DefaultInputProject project = new DefaultInputProject(rootDef, 1);
- InputComponentStore store = new InputComponentStore(branchConfiguration, sonarRuntime);
+ InputComponentStore store = new InputComponentStore(branchConfiguration);
ComponentsPublisher publisher = new ComponentsPublisher(project, store);
publisher.publish(writer);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
index f6f176d8cff..53d37e99363 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
@@ -56,7 +56,6 @@ import org.sonar.scanner.rule.QualityProfiles;
import org.sonar.scanner.scan.ScanProperties;
import org.sonar.scanner.scan.branch.BranchConfiguration;
import org.sonar.scanner.scan.branch.BranchType;
-import org.sonar.scanner.scan.filesystem.InputComponentStore;
import org.sonar.scanner.scm.ScmConfiguration;
import org.sonar.scanner.scm.ScmRevision;
@@ -74,18 +73,19 @@ public class MetadataPublisherTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
+ private DefaultInputModule rootModule;
private MetadataPublisher underTest;
- private final ScanProperties properties = mock(ScanProperties.class);
- private final QualityProfiles qProfiles = mock(QualityProfiles.class);
- private final ProjectInfo projectInfo = mock(ProjectInfo.class);
- private final CpdSettings cpdSettings = mock(CpdSettings.class);
- private final ForkDateSupplier forkDateSupplier = mock(ForkDateSupplier.class);
- private final ScannerPluginRepository pluginRepository = mock(ScannerPluginRepository.class);
+ private ScanProperties properties = mock(ScanProperties.class);
+ private QualityProfiles qProfiles = mock(QualityProfiles.class);
+ private ProjectInfo projectInfo = mock(ProjectInfo.class);
+ private CpdSettings cpdSettings = mock(CpdSettings.class);
+ private InputModuleHierarchy inputModuleHierarchy;
+ private ForkDateSupplier forkDateSupplier = mock(ForkDateSupplier.class);
+ private ScannerPluginRepository pluginRepository = mock(ScannerPluginRepository.class);
private BranchConfiguration branches;
private ScmConfiguration scmConfiguration;
- private final ScmProvider scmProvider = mock(ScmProvider.class);
- private final ScmRevision scmRevision = mock(ScmRevision.class);
- private final InputComponentStore componentStore = mock(InputComponentStore.class);
+ private ScmProvider scmProvider = mock(ScmProvider.class);
+ private ScmRevision scmRevision = mock(ScmRevision.class);
@Before
public void prepare() throws IOException {
@@ -101,11 +101,11 @@ public class MetadataPublisherTest {
Path rootBaseDir = temp.newFolder().toPath();
Path moduleBaseDir = rootBaseDir.resolve("moduleDir");
Files.createDirectory(moduleBaseDir);
- DefaultInputModule rootModule = new DefaultInputModule(def
+ rootModule = new DefaultInputModule(def
.setBaseDir(rootBaseDir.toFile())
.setKey("root")
.setWorkDir(temp.newFolder()), TestInputFileBuilder.nextBatchId());
- InputModuleHierarchy inputModuleHierarchy = mock(InputModuleHierarchy.class);
+ inputModuleHierarchy = mock(InputModuleHierarchy.class);
when(inputModuleHierarchy.root()).thenReturn(rootModule);
DefaultInputModule child = new DefaultInputModule(ProjectDefinition.create()
.setKey("module")
@@ -118,7 +118,7 @@ public class MetadataPublisherTest {
scmConfiguration = mock(ScmConfiguration.class);
when(scmConfiguration.provider()).thenReturn(scmProvider);
underTest = new MetadataPublisher(projectInfo, inputModuleHierarchy, properties, qProfiles, cpdSettings,
- pluginRepository, branches, scmRevision, forkDateSupplier, componentStore, scmConfiguration);
+ pluginRepository, branches, scmRevision, forkDateSupplier, scmConfiguration);
}
@Test
@@ -141,7 +141,6 @@ public class MetadataPublisherTest {
assertThat(metadata.getProjectKey()).isEqualTo("root");
assertThat(metadata.getModulesProjectRelativePathByKeyMap()).containsOnly(entry("module", "modulePath"), entry("root", ""));
assertThat(metadata.getProjectVersion()).isEmpty();
- assertThat(metadata.getNotAnalyzedFilesByLanguageCount()).isZero();
assertThat(metadata.getQprofilesPerLanguageMap()).containsOnly(entry("java", org.sonar.scanner.protocol.output.ScannerReport.Metadata.QProfile.newBuilder()
.setKey("q1")
.setName("Q1")
@@ -149,9 +148,9 @@ public class MetadataPublisherTest {
.setRulesUpdatedAt(date.getTime())
.build()));
assertThat(metadata.getPluginsByKey()).containsOnly(entry("java", org.sonar.scanner.protocol.output.ScannerReport.Metadata.Plugin.newBuilder()
- .setKey("java")
- .setUpdatedAt(12345)
- .build()),
+ .setKey("java")
+ .setUpdatedAt(12345)
+ .build()),
entry("php", org.sonar.scanner.protocol.output.ScannerReport.Metadata.Plugin.newBuilder()
.setKey("php")
.setUpdatedAt(45678)
@@ -159,20 +158,6 @@ public class MetadataPublisherTest {
}
@Test
- public void write_not_analysed_file_counts() throws Exception {
- when(componentStore.getNotAnalysedFilesByLanguage()).thenReturn(ImmutableMap.of("c", 10, "cpp", 20));
-
- File outputDir = temp.newFolder();
- ScannerReportWriter writer = new ScannerReportWriter(outputDir);
-
- underTest.publish(writer);
-
- ScannerReportReader reader = new ScannerReportReader(outputDir);
- ScannerReport.Metadata metadata = reader.readMetadata();
- assertThat(metadata.getNotAnalyzedFilesByLanguageMap()).contains(entry("c", 10), entry("cpp", 20));
- }
-
- @Test
public void write_project_organization() throws Exception {
when(properties.organizationKey()).thenReturn(Optional.of("SonarSource"));
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/SourcePublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/SourcePublisherTest.java
index de69cdaea76..4de345c222f 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/SourcePublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/SourcePublisherTest.java
@@ -27,7 +27,6 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
@@ -59,7 +58,7 @@ public class SourcePublisherTest {
.build();
DefaultInputProject rootProject = TestInputFileBuilder.newDefaultInputProject(moduleKey, baseDir);
- InputComponentStore componentStore = new InputComponentStore(mock(BranchConfiguration.class), mock(SonarRuntime.class));
+ InputComponentStore componentStore = new InputComponentStore(mock(BranchConfiguration.class));
componentStore.put(moduleKey, inputFile);
publisher = new SourcePublisher(componentStore);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
index 4720972d391..c427e5c9ccf 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
@@ -24,7 +24,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.slf4j.Logger;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.scanner.scan.branch.BranchConfiguration;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
@@ -43,7 +42,7 @@ public class QProfileVerifierTest {
@Before
public void before() {
- store = new InputComponentStore(mock(BranchConfiguration.class), mock(SonarRuntime.class));
+ store = new InputComponentStore(mock(BranchConfiguration.class));
profiles = mock(QualityProfiles.class);
QProfile javaProfile = new QProfile("p1", "My Java profile", "java", null);
when(profiles.findByLanguage("java")).thenReturn(javaProfile);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleIndexerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleIndexerTest.java
index b3786854552..2a581f0c5ee 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleIndexerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleIndexerTest.java
@@ -21,7 +21,6 @@ package org.sonar.scanner.scan;
import java.util.Arrays;
import org.junit.Test;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.scanner.scan.branch.BranchConfiguration;
@@ -36,7 +35,7 @@ public class ModuleIndexerTest {
private DefaultInputModuleHierarchy moduleHierarchy;
public void createIndexer() {
- InputComponentStore componentStore = new InputComponentStore(mock(BranchConfiguration.class), mock(SonarRuntime.class));
+ InputComponentStore componentStore = new InputComponentStore(mock(BranchConfiguration.class));
moduleHierarchy = mock(DefaultInputModuleHierarchy.class);
indexer = new ModuleIndexer(componentStore, moduleHierarchy);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java
index f435cef1532..abfbabcce30 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java
@@ -24,12 +24,9 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
-import javax.annotation.Nullable;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.SonarEdition;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFile.Status;
@@ -41,16 +38,10 @@ import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.scanner.scan.branch.BranchConfiguration;
-import static java.util.Optional.ofNullable;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.tuple;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class InputComponentStoreTest {
-
- private final SonarRuntime sonarRuntime = mock(SonarRuntime.class);
-
@ClassRule
public static TemporaryFolder temp = new TemporaryFolder();
@@ -69,7 +60,7 @@ public class InputComponentStoreTest {
DefaultInputProject rootProject = TestInputFileBuilder.newDefaultInputProject(rootDef);
DefaultInputModule subModule = TestInputFileBuilder.newDefaultInputModule(moduleDef);
- InputComponentStore store = new InputComponentStore(mock(BranchConfiguration.class), sonarRuntime);
+ InputComponentStore store = new InputComponentStore(mock(BranchConfiguration.class));
store.put(subModule);
DefaultInputFile fooFile = new TestInputFileBuilder(rootModuleKey, "src/main/java/Foo.java")
@@ -104,20 +95,13 @@ public class InputComponentStoreTest {
}
static class InputComponentStoreTester extends InputComponentStore {
- InputComponentStoreTester(SonarRuntime sonarRuntime) {
- super(mock(BranchConfiguration.class), sonarRuntime);
- }
-
- InputFile addFile(String moduleKey, String relpath, @Nullable String language) {
- TestInputFileBuilder fileBuilder = new TestInputFileBuilder(moduleKey, relpath);
- ofNullable(language).ifPresent(fileBuilder::setLanguage);
- DefaultInputFile file = fileBuilder.build();
- put(moduleKey, file);
- return file;
+ InputComponentStoreTester() {
+ super(mock(BranchConfiguration.class));
}
- InputFile addFile(String moduleKey, String relPath) {
- DefaultInputFile file = new TestInputFileBuilder(moduleKey, relPath)
+ InputFile addFile(String moduleKey, String relpath, String language) {
+ DefaultInputFile file = new TestInputFileBuilder(moduleKey, relpath)
+ .setLanguage(language)
.build();
put(moduleKey, file);
return file;
@@ -125,8 +109,8 @@ public class InputComponentStoreTest {
}
@Test
- public void should_add_languages_per_module_and_globally() {
- InputComponentStoreTester tester = new InputComponentStoreTester(sonarRuntime);
+ public void should_add_languages_per_module_and_globally() throws IOException {
+ InputComponentStoreTester tester = new InputComponentStoreTester();
String mod1Key = "mod1";
tester.addFile(mod1Key, "src/main/java/Foo.java", "java");
@@ -140,8 +124,8 @@ public class InputComponentStoreTest {
}
@Test
- public void should_find_files_per_module_and_globally() {
- InputComponentStoreTester tester = new InputComponentStoreTester(sonarRuntime);
+ public void should_find_files_per_module_and_globally() throws IOException {
+ InputComponentStoreTester tester = new InputComponentStoreTester();
String mod1Key = "mod1";
InputFile mod1File = tester.addFile(mod1Key, "src/main/java/Foo.java", "java");
@@ -153,55 +137,4 @@ public class InputComponentStoreTest {
assertThat(tester.filesByModule(mod2Key)).containsExactly(mod2File);
assertThat(tester.inputFiles()).containsExactlyInAnyOrder(mod1File, mod2File);
}
-
- @Test
- public void stores_not_analysed_c_file_count_in_sq_community_edition() {
- when(sonarRuntime.getEdition()).thenReturn(SonarEdition.COMMUNITY);
- InputComponentStoreTester underTest = new InputComponentStoreTester(sonarRuntime);
- String mod1Key = "mod1";
- underTest.addFile(mod1Key, "src/main/java/Foo.java", "java");
- underTest.addFile(mod1Key, "src/main/c/file1.c");
- underTest.addFile(mod1Key, "src/main/c/file2.c");
- String mod2Key = "mod2";
- underTest.addFile(mod2Key, "src/main/groovy/Foo.groovy", "groovy");
- underTest.addFile(mod2Key, "src/main/c/file3.c");
-
- assertThat(underTest.getNotAnalysedFilesByLanguage()).hasSize(1);
- assertThat(underTest.getNotAnalysedFilesByLanguage()).containsEntry("C", 3);
- }
-
- @Test
- public void stores_not_analysed_cpp_file_count_in_sq_community_edition() {
- when(sonarRuntime.getEdition()).thenReturn(SonarEdition.COMMUNITY);
- InputComponentStoreTester underTest = new InputComponentStoreTester(sonarRuntime);
- String mod1Key = "mod1";
- underTest.addFile(mod1Key, "src/main/java/Foo.java", "java");
- underTest.addFile(mod1Key, "src/main/c/file1.c");
- underTest.addFile(mod1Key, "src/main/c/file2.cpp");
- underTest.addFile(mod1Key, "src/main/c/file3.cxx");
- underTest.addFile(mod1Key, "src/main/c/file4.c++");
- underTest.addFile(mod1Key, "src/main/c/file5.cc");
- underTest.addFile(mod1Key, "src/main/c/file6.CPP");
- String mod2Key = "mod2";
- underTest.addFile(mod2Key, "src/main/groovy/Foo.groovy", "groovy");
- underTest.addFile(mod2Key, "src/main/c/file3.cpp");
-
- assertThat(underTest.getNotAnalysedFilesByLanguage()).hasSize(2);
- assertThat(underTest.getNotAnalysedFilesByLanguage()).containsEntry("C++", 6);
- }
-
- @Test
- public void does_not_store_not_analysed_file_counts_in_sq_non_community_editions() {
- when(sonarRuntime.getEdition()).thenReturn(SonarEdition.DEVELOPER);
- InputComponentStoreTester underTest = new InputComponentStoreTester(sonarRuntime);
- String mod1Key = "mod1";
- underTest.addFile(mod1Key, "src/main/java/Foo.java", "java");
- underTest.addFile(mod1Key, "src/main/java/file1.c");
- underTest.addFile(mod1Key, "src/main/java/file2.c");
- String mod2Key = "mod2";
- underTest.addFile(mod2Key, "src/main/groovy/Foo.groovy", "groovy");
- underTest.addFile(mod2Key, "src/main/groovy/file4.c");
-
- assertThat(underTest.getNotAnalysedFilesByLanguage()).isEmpty();
- }
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java
index 522172db47f..0b9e8b2571a 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java
@@ -24,7 +24,6 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputModule;
import org.sonar.api.batch.fs.internal.SensorStrategy;
@@ -50,7 +49,7 @@ public class ModuleInputComponentStoreTest {
@Before
public void setUp() throws IOException {
DefaultInputProject root = TestInputFileBuilder.newDefaultInputProject(projectKey, temp.newFolder());
- componentStore = new InputComponentStore(mock(BranchConfiguration.class), mock(SonarRuntime.class));
+ componentStore = new InputComponentStore(mock(BranchConfiguration.class));
}
@Test
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
index 20b8f682017..7349fa688f8 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
@@ -32,12 +32,9 @@ import java.util.Map;
import java.util.Scanner;
import javax.annotation.CheckForNull;
import javax.swing.*;
-import javax.swing.UIManager.LookAndFeelInfo;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeSelectionModel;
+import javax.swing.UIManager.*;
+import javax.swing.event.*;
+import javax.swing.tree.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.core.util.CloseableIterator;
@@ -97,8 +94,6 @@ public class ScannerReportViewerApp {
private JEditorPane cpdTextBlocksEditor;
private JScrollPane significantCodeTab;
private JEditorPane significantCodeEditor;
- private JScrollPane metadataTab;
- private JEditorPane metadataEditor;
/**
* Create the application.
@@ -192,7 +187,6 @@ public class ScannerReportViewerApp {
updateAdHocRules();
updateQualityProfiles();
updatePlugins();
- updateMetadata();
}
private void loadComponents() {
@@ -354,21 +348,6 @@ public class ScannerReportViewerApp {
}
}
- private void updateMetadata() {
- metadataEditor.setText("");
-
- StringBuilder builder = new StringBuilder();
- Metadata data = reader.readMetadata();
- builder.append("Project key: ").append(data.getProjectKey()).append("\n");
- builder.append("Project version: ").append(data.getProjectVersion()).append("\n");
- builder.append("Scm revision ID: ").append(data.getScmRevisionId()).append("\n");
- if (data.getNotAnalyzedFilesByLanguageCount() > 0) {
- builder.append("Not analyzed files in project:").append("\n");
- data.getNotAnalyzedFilesByLanguageMap().forEach((key, value) -> builder.append(" ").append(key).append(": ").append(value).append("\n"));
- }
- metadataEditor.setText(builder.toString());
- }
-
private void updateActiveRules() {
activeRuleEditor.setText("");
@@ -609,12 +588,6 @@ public class ScannerReportViewerApp {
significantCodeEditor = new JEditorPane();
significantCodeTab.setViewportView(significantCodeEditor);
- metadataTab = new JScrollPane();
- tabbedPane.addTab("Metadata", null, metadataTab, null);
-
- metadataEditor = new JEditorPane();
- metadataTab.setViewportView(metadataEditor);
-
treeScrollPane = new JScrollPane();
treeScrollPane.setPreferredSize(new Dimension(200, 400));
splitPane.setLeftComponent(treeScrollPane);
diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
index 3e3a1f80351..b984bf7abbb 100644
--- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
+++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
@@ -58,8 +58,6 @@ message Metadata {
int64 forkDate = 19;
- map<string, int32> not_analyzed_files_by_language = 20;
-
message QProfile {
string key = 1;
string name = 2;