diff options
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java | 24 | ||||
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java | 48 |
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); |