aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJanos Gyerik <janos.gyerik@sonarsource.com>2017-10-11 16:51:21 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-10-12 09:56:30 +0200
commite146d1732e5b3671aa56e9fc32e9149345aea403 (patch)
tree7baa930d04a6de3a5589254334b0eceb73222a59 /sonar-scanner-engine
parente9e277c47db4fd089cbcbeb6b533a3a808bed641 (diff)
downloadsonarqube-e146d1732e5b3671aa56e9fc32e9149345aea403.tar.gz
sonarqube-e146d1732e5b3671aa56e9fc32e9149345aea403.zip
Revert "SONAR-9757 Copy issues in directories with unchanged files only"
This reverts commit aa5537ba9748dd4f3f9c876064ff6a6e641cba3e.
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java24
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java48
2 files changed, 0 insertions, 72 deletions
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 7995b30cd1b..9863ba0cdba 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
@@ -117,11 +117,6 @@ public class ComponentsPublisher implements ReportPublisherStep {
if (lang != null) {
builder.setLanguage(lang);
}
- } else if (component instanceof InputDir) {
- FileStatus status = getDirectoryStatus(component, children);
- if (status != null) {
- builder.setStatus(status);
- }
}
String path = getPath(component);
@@ -150,25 +145,6 @@ public class ComponentsPublisher implements ReportPublisherStep {
}
}
- @CheckForNull
- private static FileStatus getDirectoryStatus(InputComponent component, Collection<InputComponent> children) {
- if (children.isEmpty()) {
- // directory must have issues, otherwise wouldn't be written
- return null;
- }
-
- boolean hasChangedFiles = children.stream()
- .filter(c -> c instanceof InputFile)
- .map(c -> (DefaultInputFile) c)
- .anyMatch(f -> f.isPublished() && f.status() != Status.SAME);
-
- if (!hasChangedFiles) {
- // this means that SonarJava didn't analyze the directory
- return FileStatus.SAME;
- }
- return null;
- }
-
private boolean shouldSkipComponent(DefaultInputComponent component, Collection<InputComponent> children) {
if (component instanceof InputModule && children.isEmpty() && branchConfiguration.isShortLivingBranch()) {
// no children on a module in short branch analysis -> skip it (except root)
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 00c496be9ab..1f017e7ada9 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
@@ -289,54 +289,6 @@ public class ComponentsPublisherTest {
}
@Test
- public void should_set_directory_status() throws IOException {
- ProjectAnalysisInfo projectAnalysisInfo = mock(ProjectAnalysisInfo.class);
- when(projectAnalysisInfo.analysisDate()).thenReturn(DateUtils.parseDate("2012-12-12"));
-
- ProjectDefinition rootDef = ProjectDefinition.create()
- .setKey("foo")
- .setProperty(CoreProperties.PROJECT_VERSION_PROPERTY, "1.0")
- .setName("Root project")
- .setDescription("Root description")
- .setBaseDir(temp.newFolder())
- .setWorkDir(temp.newFolder());
- DefaultInputModule root = new DefaultInputModule(rootDef, 1);
-
- moduleHierarchy = mock(InputModuleHierarchy.class);
- when(moduleHierarchy.root()).thenReturn(root);
- when(moduleHierarchy.children(root)).thenReturn(Collections.emptyList());
-
- // dir with unchanged files
- DefaultInputDir dir = new DefaultInputDir("module1", "src", 2);
- tree.index(dir, root);
-
- // dir with changed files
- DefaultInputDir dir2 = new DefaultInputDir("module1", "src2", 3);
- tree.index(dir2, root);
-
- DefaultInputFile file = new TestInputFileBuilder("module1", "src/Foo.java", 4).setLines(2).setStatus(InputFile.Status.SAME).build();
- tree.index(file, dir);
-
- DefaultInputFile file2 = new TestInputFileBuilder("module1", "src/Foo.java", 5).setLines(2).setStatus(InputFile.Status.ADDED).build();
- tree.index(file2, dir2);
-
- ComponentsPublisher publisher = new ComponentsPublisher(moduleHierarchy, tree, branchConfiguration);
- publisher.publish(writer);
-
- assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isTrue();
- assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 2)).isTrue();
- assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 3)).isTrue();
- assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 4)).isTrue();
- assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 5)).isTrue();
-
- // directory is unchanged because its files are unchanged
- assertThat(reader.readComponent(2).getStatus()).isEqualTo(FileStatus.SAME);
- // status not set
- assertThat(reader.readComponent(3).getStatus()).isEqualTo(FileStatus.UNAVAILABLE);
-
- }
-
- @Test
public void skip_unchanged_components_in_short_branches() throws IOException {
when(branchConfiguration.isShortLivingBranch()).thenReturn(true);
ProjectAnalysisInfo projectAnalysisInfo = mock(ProjectAnalysisInfo.class);