]> source.dussan.org Git - sonarqube.git/commitdiff
Revert "SONAR-9757 Copy issues in directories with unchanged files only"
authorJanos Gyerik <janos.gyerik@sonarsource.com>
Wed, 11 Oct 2017 14:51:21 +0000 (16:51 +0200)
committerJanos Gyerik <janos.gyerik@sonarsource.com>
Thu, 12 Oct 2017 07:56:30 +0000 (09:56 +0200)
This reverts commit aa5537ba9748dd4f3f9c876064ff6a6e641cba3e.

sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java

index 7995b30cd1be396f1c6d525e053e9c7b19d766a3..9863ba0cdba591b63089e1bdc0d2ff9f0fd6d8ac 100644 (file)
@@ -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)
index 00c496be9aba0bb69dc91d64729ba62e4b29a041..1f017e7ada98068302b9b2e07fb4f199b7698409 100644 (file)
@@ -288,54 +288,6 @@ public class ComponentsPublisherTest {
     assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 3)).isFalse();
   }
 
-  @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);