]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8701 Store number of lines of files in compute engine Component
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 25 Jan 2017 14:16:02 +0000 (15:16 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 27 Jan 2017 15:26:30 +0000 (16:26 +0100)
28 files changed:
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentRootBuilder.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/FileAttributes.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentRootBuilderTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ReportComponent.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/commonrule/CommentDensityRuleTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/commonrule/CommonRuleEngineImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/commonrule/CoverageRuleTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/commonrule/DuplicatedBlockRuleTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/commonrule/SkippedTestRuleTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/commonrule/TestErrorRuleTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/MaintainabilityMeasuresVisitorTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitorTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/NewReliabilityAndSecurityRatingMeasuresVisitorTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/source/LastCommitVisitorTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/BuildComponentTreeStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ComputeQProfileMeasureStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistTestsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportCoverageMeasuresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportLanguageDistributionMeasuresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportNewCoverageMeasuresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportSizeMeasuresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportUnitTestMeasuresStepTest.java
sonar-scanner-protocol/src/main/protobuf/scanner_report.proto

index 885500e7f8e6bb08382bdc457c47ecc352cc72fc..dc2b3cfc8e7b7ad35528c5790e41c40176bb9c9c 100644 (file)
@@ -191,7 +191,8 @@ public class ComponentRootBuilder {
 
     return new FileAttributes(
       component.getIsTest(),
-      trimToNull(component.getLanguage()));
+      trimToNull(component.getLanguage()),
+      component.getLines());
   }
 
   @VisibleForTesting
index 43e6101220a729bfcb7cb2fceaf8276ba16e4b25..a096500c92ce72d115618ce7e8ecc0e777fda99c 100644 (file)
@@ -23,6 +23,8 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 /**
  * The attributes specific to a Component of type {@link org.sonar.server.computation.task.projectanalysis.component.Component.Type#FILE}.
  */
@@ -31,10 +33,13 @@ public class FileAttributes {
   private final boolean unitTest;
   @CheckForNull
   private final String languageKey;
+  private final int lines;
 
-  public FileAttributes(boolean unitTest, @Nullable String languageKey) {
+  public FileAttributes(boolean unitTest, @Nullable String languageKey, int lines) {
     this.unitTest = unitTest;
     this.languageKey = languageKey;
+    checkArgument(lines > 0, "Lines has not been set for this file");
+    this.lines = lines;
   }
 
   public boolean isUnitTest() {
@@ -46,11 +51,16 @@ public class FileAttributes {
     return languageKey;
   }
 
+  public int getLines() {
+    return lines;
+  }
+
   @Override
   public String toString() {
     return "FileAttributes{" +
       "languageKey='" + languageKey + '\'' +
       ", unitTest=" + unitTest +
+      ", lines=" + lines +
       '}';
   }
 }
index 1d8c006551955bc895900caa6b334000accdf630..e9d745e50c16fe73ddf76a9d80dfde0da5ab86af 100644 (file)
@@ -105,7 +105,7 @@ public class ComponentImplTest {
 
   @Test
   public void isUnitTest_returns_true_if_IsTest_is_set_in_BatchComponent() {
-    ComponentImpl component = buildSimpleComponent(FILE, "file").setFileAttributes(new FileAttributes(true, null)).build();
+    ComponentImpl component = buildSimpleComponent(FILE, "file").setFileAttributes(new FileAttributes(true, null, 1)).build();
 
     assertThat(component.getFileAttributes().isUnitTest()).isTrue();
   }
@@ -113,7 +113,7 @@ public class ComponentImplTest {
   @Test
   public void isUnitTest_returns_value_of_language_of_BatchComponent() {
     String languageKey = "some language key";
-    ComponentImpl component = buildSimpleComponent(FILE, "file").setFileAttributes(new FileAttributes(false, languageKey)).build();
+    ComponentImpl component = buildSimpleComponent(FILE, "file").setFileAttributes(new FileAttributes(false, languageKey, 1)).build();
 
     assertThat(component.getFileAttributes().getLanguageKey()).isEqualTo(languageKey);
   }
index bae25d174830ca95f24d69f4fbefdf7690511f17..7a39a042ccc55700a1e023ae5945ab6f2a5fb7fc 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Map;
 import java.util.function.Function;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.junit.rules.ExternalResource;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.SnapshotDto;
@@ -68,6 +69,9 @@ public class ComponentRootBuilderTest {
   private static final String PROJECT_UUID = "project uuid";
   private static final String DEFAULT_VERSION = "not provided";
 
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
   @Rule
   public ScannerComponentProvider scannerComponentProvider = new ScannerComponentProvider();
 
@@ -139,7 +143,7 @@ public class ComponentRootBuilderTest {
     ScannerReport.Component project = newBuilder().setType(PROJECT).setRef(1).addChildRef(2).build();
     scannerComponentProvider.add(newBuilder().setRef(2).setType(MODULE).setKey(MODULE_KEY).addChildRef(3));
     scannerComponentProvider.add(newBuilder().setRef(3).setType(DIRECTORY).setPath(DIRECTORY_PATH).addChildRef(4));
-    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH));
+    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH).setLines(1));
 
     String branch = "BRANCH";
     ComponentRootBuilder builder = new ComponentRootBuilder(branch, SIMPLE_UUID_GENERATOR, scannerComponentProvider, NO_COMPONENT_DTO_FOR_PROJECT, NO_BASEANALYSIS);
@@ -163,7 +167,7 @@ public class ComponentRootBuilderTest {
     ScannerReport.Component project = newBuilder().setType(PROJECT).setRef(1).addChildRef(2).build();
     scannerComponentProvider.add(newBuilder().setRef(2).setType(MODULE).setKey(MODULE_KEY).addChildRef(3));
     scannerComponentProvider.add(newBuilder().setRef(3).setType(DIRECTORY).setPath(DIRECTORY_PATH).addChildRef(4));
-    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH));
+    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH).setLines(1));
 
     Component root = underTest.build(project, PROJECT_KEY);
     assertThat(root.getKey()).isEqualTo(PROJECT_KEY);
@@ -180,7 +184,7 @@ public class ComponentRootBuilderTest {
     ScannerReport.Component project = newBuilder().setType(PROJECT).setRef(1).setName("").addChildRef(2).build();
     scannerComponentProvider.add(newBuilder().setRef(2).setType(MODULE).setKey(MODULE_KEY).setName("").addChildRef(3));
     scannerComponentProvider.add(newBuilder().setRef(3).setType(DIRECTORY).setPath(DIRECTORY_PATH).setName("").addChildRef(4));
-    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH).setName(""));
+    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH).setName("").setLines(1));
 
     Component root = underTest.build(project, PROJECT_KEY);
     assertThat(root.getKey()).isEqualTo(PROJECT_KEY);
@@ -202,14 +206,14 @@ public class ComponentRootBuilderTest {
     scannerComponentProvider.add(newBuilder().setRef(22).setType(DIRECTORY).setPath("directory in module 1").addChildRef(36));
     scannerComponentProvider.add(newBuilder().setRef(23).setType(DIRECTORY).setPath("directory in module 2").addChildRef(37));
     scannerComponentProvider.add(newBuilder().setRef(24).setType(DIRECTORY).setPath("directory in module 3").addChildRef(38));
-    scannerComponentProvider.add(newBuilder().setRef(31).setType(FILE).setPath("file in project"));
-    scannerComponentProvider.add(newBuilder().setRef(32).setType(FILE).setPath("file in module 1"));
-    scannerComponentProvider.add(newBuilder().setRef(33).setType(FILE).setPath("file in module 2"));
-    scannerComponentProvider.add(newBuilder().setRef(34).setType(FILE).setPath("file in module 3"));
-    scannerComponentProvider.add(newBuilder().setRef(35).setType(FILE).setPath("file in directory in project"));
-    scannerComponentProvider.add(newBuilder().setRef(36).setType(FILE).setPath("file in directory in module 1"));
-    scannerComponentProvider.add(newBuilder().setRef(37).setType(FILE).setPath("file in directory in module 2"));
-    scannerComponentProvider.add(newBuilder().setRef(38).setType(FILE).setPath("file in directory in module 3"));
+    scannerComponentProvider.add(newBuilder().setRef(31).setType(FILE).setPath("file in project").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(32).setType(FILE).setPath("file in module 1").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(33).setType(FILE).setPath("file in module 2").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(34).setType(FILE).setPath("file in module 3").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(35).setType(FILE).setPath("file in directory in project").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(36).setType(FILE).setPath("file in directory in module 1").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(37).setType(FILE).setPath("file in directory in module 2").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(38).setType(FILE).setPath("file in directory in module 3").setLines(1));
 
     Component root = underTest.build(project, PROJECT_KEY);
     Map<Integer, Component> componentsByRef = indexComponentByRef(root);
@@ -337,7 +341,7 @@ public class ComponentRootBuilderTest {
     ScannerReport.Component project = newBuilder().setType(PROJECT).setRef(1).addChildRef(2).build();
     scannerComponentProvider.add(newBuilder().setRef(2).setType(MODULE).setKey(MODULE_KEY).addChildRef(3));
     scannerComponentProvider.add(newBuilder().setRef(3).setType(DIRECTORY).setPath(DIRECTORY_PATH).addChildRef(4));
-    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH));
+    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setPath(FILE_PATH).setLines(1));
 
     Component root = underTest.build(project, PROJECT_KEY);
     Map<Integer, Component> componentByRef = indexComponentByRef(root);
@@ -353,7 +357,7 @@ public class ComponentRootBuilderTest {
     ScannerReport.Component project = newBuilder().setType(PROJECT).setRef(1).addChildRef(2).build();
     scannerComponentProvider.add(newBuilder().setRef(2).setType(MODULE).addChildRef(3));
     scannerComponentProvider.add(newBuilder().setRef(3).setType(DIRECTORY).addChildRef(4));
-    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE));
+    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setLines(1));
 
     Component root = underTest.build(project, PROJECT_KEY);
     Map<Integer, Component> componentByRef = indexComponentByRef(root);
@@ -368,7 +372,7 @@ public class ComponentRootBuilderTest {
     ScannerReport.Component project = newBuilder().setType(PROJECT).setRef(1).setDescription("").addChildRef(2).build();
     scannerComponentProvider.add(newBuilder().setRef(2).setType(MODULE).setDescription("").addChildRef(3));
     scannerComponentProvider.add(newBuilder().setRef(3).setType(DIRECTORY).setDescription("").addChildRef(4));
-    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setDescription(""));
+    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setLines(1).setDescription(""));
 
     Component root = underTest.build(project, PROJECT_KEY);
     Map<Integer, Component> componentByRef = indexComponentByRef(root);
@@ -383,7 +387,7 @@ public class ComponentRootBuilderTest {
     ScannerReport.Component project = newBuilder().setType(PROJECT).setRef(1).setDescription("desc of project").addChildRef(2).build();
     scannerComponentProvider.add(newBuilder().setRef(2).setType(MODULE).setDescription("desc of module").addChildRef(3));
     scannerComponentProvider.add(newBuilder().setRef(3).setType(DIRECTORY).setDescription("desc of directory").addChildRef(4));
-    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setDescription("desc of file"));
+    scannerComponentProvider.add(newBuilder().setRef(4).setType(FILE).setLines(1).setDescription("desc of file"));
 
     Component root = underTest.build(project, PROJECT_KEY);
     Map<Integer, Component> componentByRef = indexComponentByRef(root);
@@ -466,18 +470,37 @@ public class ComponentRootBuilderTest {
 
   @Test
   public void createFileAttributes_sets_language_to_null_when_unset_in_Scanner_Component() {
-    assertThat(createFileAttributes(newBuilder().setType(FILE).build()).getLanguageKey()).isNull();
+    assertThat(createFileAttributes(newBuilder().setType(FILE).setLines(1).build()).getLanguageKey()).isNull();
   }
 
   @Test
   public void createFileAttributes_sets_language_to_null_when_empty_in_Scanner_Component() {
-    assertThat(createFileAttributes(newBuilder().setType(FILE).setLanguage("").build()).getLanguageKey()).isNull();
+    assertThat(createFileAttributes(newBuilder().setType(FILE).setLanguage("").setLines(1).build()).getLanguageKey()).isNull();
   }
 
   @Test
   public void createFileAttributes_sets_unitTest_from_Scanner_Component() {
-    assertThat(createFileAttributes(newBuilder().setType(FILE).build()).isUnitTest()).isFalse();
-    assertThat(createFileAttributes(newBuilder().setType(FILE).setIsTest(true).build()).isUnitTest()).isTrue();
+    assertThat(createFileAttributes(newBuilder().setType(FILE).setLines(1).build()).isUnitTest()).isFalse();
+    assertThat(createFileAttributes(newBuilder().setType(FILE).setIsTest(true).setLines(1).build()).isUnitTest()).isTrue();
+  }
+
+  @Test
+  public void createFileAttributes_sets_lines_in_Scanner_Component() {
+    assertThat(createFileAttributes(newBuilder().setType(FILE).setLines(10).build()).getLines()).isEqualTo(10);
+  }
+
+  @Test
+  public void fail_with_IAE_when_createFileAttributes_sets_lines_to_0() throws Exception {
+    expectedException.expect(IllegalArgumentException.class);
+    expectedException.expectMessage("Lines has not been set for this file");
+    createFileAttributes(newBuilder().setType(FILE).setLines(0).build());
+  }
+
+  @Test
+  public void fail_with_IAE_when_createFileAttributes_lines_is_not_set() throws Exception {
+    expectedException.expect(IllegalArgumentException.class);
+    expectedException.expectMessage("Lines has not been set for this file");
+    createFileAttributes(newBuilder().setType(FILE).build());
   }
 
   private static class ScannerComponentProvider extends ExternalResource implements Function<Integer, ScannerReport.Component> {
index cbf9e99fd90a48d212255ed0fc5e68b378f31bb5..64023bd0ad2e1d070a2941d01567cb7054c173d2 100644 (file)
@@ -35,7 +35,7 @@ import static java.util.Arrays.asList;
  */
 public class ReportComponent implements Component {
 
-  private static final FileAttributes DEFAULT_FILE_ATTRIBUTES = new FileAttributes(false, null);
+  private static final FileAttributes DEFAULT_FILE_ATTRIBUTES = new FileAttributes(false, null, 1);
 
   public static final Component DUMB_PROJECT = builder(Type.PROJECT, 1).setKey("PROJECT_KEY").setUuid("PROJECT_UUID").setName("Project Name").setVersion("1.0-SNAPSHOT").build();
 
index b14e16a393bfeb866643956ed1f8c47cd234b9a6..ababe9d888bd884c79e31f8610ae5a98807a5fbc 100644 (file)
@@ -25,8 +25,8 @@ import java.util.Collection;
 import java.util.Collections;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.Settings;
 import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.Settings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.duplications.block.Block;
@@ -54,7 +54,7 @@ public class IntegrateCrossProjectDuplicationsTest {
   static final String ORIGIN_FILE_KEY = "ORIGIN_FILE_KEY";
   static final Component ORIGIN_FILE = builder(FILE, 1)
     .setKey(ORIGIN_FILE_KEY)
-    .setFileAttributes(new FileAttributes(false, XOO_LANGUAGE))
+    .setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1))
     .build();
 
   static final String OTHER_FILE_KEY = "OTHER_FILE_KEY";
@@ -226,7 +226,7 @@ public class IntegrateCrossProjectDuplicationsTest {
   public void add_duplication_for_java_even_when_no_token() {
     Component javaFile = builder(FILE, 1)
       .setKey(ORIGIN_FILE_KEY)
-      .setFileAttributes(new FileAttributes(false, "java"))
+      .setFileAttributes(new FileAttributes(false, "java", 10))
       .build();
 
     Collection<Block> originBlocks = singletonList(
index bacf258de6241afea37e8602bfd865bf1ff78200..fc482f87de220f769182c3d277c3fc7b058ae90d 100644 (file)
@@ -27,10 +27,10 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.core.issue.DefaultIssue;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
-import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
@@ -46,7 +46,7 @@ public class CommentDensityRuleTest {
   static RuleKey RULE_KEY = RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY);
 
   static ReportComponent FILE = ReportComponent.builder(Component.Type.FILE, 1)
-    .setFileAttributes(new FileAttributes(false, "java"))
+    .setFileAttributes(new FileAttributes(false, "java", 1))
     .build();
 
   @Rule
index 24abda535fe25dbcd24a3505b1e907965afe2f33..3ad2a27b42ddd3d7ce35ce3f08a3f98102f3b4d4 100644 (file)
@@ -23,8 +23,8 @@ import java.util.Collection;
 import org.junit.Test;
 import org.sonar.core.issue.DefaultIssue;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
-import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -42,7 +42,7 @@ public class CommonRuleEngineImplTest {
   public void process_files_with_known_language() throws Exception {
     ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1)
       .setKey("FILE_KEY").setUuid("FILE_UUID")
-      .setFileAttributes(new FileAttributes(false, "java"))
+      .setFileAttributes(new FileAttributes(false, "java", 1))
       .build();
     DefaultIssue issue = new DefaultIssue();
     when(rule1.processFile(file, "java")).thenReturn(issue);
@@ -56,7 +56,7 @@ public class CommonRuleEngineImplTest {
   public void do_not_process_files_with_unknown_language() throws Exception {
     ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1)
       .setKey("FILE_KEY").setUuid("FILE_UUID")
-      .setFileAttributes(new FileAttributes(false, null))
+      .setFileAttributes(new FileAttributes(false, null, 1))
       .build();
 
     Collection<DefaultIssue> issues = underTest.process(file);
index 3a3a602f3351f5ab2dddb8a4352ce9910f3ccfda..e6caaed3a0567b1e0598544a2489af6b4a88ee30 100644 (file)
@@ -27,10 +27,10 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.core.issue.DefaultIssue;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
-import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
@@ -43,7 +43,7 @@ import static org.sonar.server.computation.task.projectanalysis.component.Report
 public abstract class CoverageRuleTest {
 
   static ReportComponent FILE = ReportComponent.builder(Component.Type.FILE, 1)
-    .setFileAttributes(new FileAttributes(false, "java"))
+    .setFileAttributes(new FileAttributes(false, "java", 1))
     .build();
 
   @Rule
index be3ec0acd4eb4f48e6b63911a85aba5a3a45ebe2..013acccfc21dc2458024eac8d8b9fdfff2203f9d 100644 (file)
@@ -26,10 +26,10 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.core.issue.DefaultIssue;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
-import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
@@ -45,7 +45,7 @@ public class DuplicatedBlockRuleTest {
   static RuleKey RULE_KEY = RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), CommonRuleKeys.DUPLICATED_BLOCKS);
 
   static ReportComponent FILE = ReportComponent.builder(Component.Type.FILE, 1)
-    .setFileAttributes(new FileAttributes(false, "java"))
+    .setFileAttributes(new FileAttributes(false, "java", 1))
     .build();
 
   @Rule
index 9768a74597ef16f00aa4c9e4ba58251b2a67c98b..3a8d5daa7c05f6eff7bc4908ea42c60e17d594fb 100644 (file)
@@ -26,10 +26,10 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.core.issue.DefaultIssue;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
-import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
@@ -45,7 +45,7 @@ public class SkippedTestRuleTest {
   static RuleKey RULE_KEY = RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), CommonRuleKeys.SKIPPED_UNIT_TESTS);
 
   static ReportComponent FILE = ReportComponent.builder(Component.Type.FILE, 1)
-    .setFileAttributes(new FileAttributes(true, "java"))
+    .setFileAttributes(new FileAttributes(true, "java", 1))
     .setName("FooTest.java")
     .build();
 
index c34ed0400bf967686899457243eb7f60a05a78ba..4ea1147c4a78b3d8ac6cfbc520e48e7679476c1a 100644 (file)
@@ -26,10 +26,10 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.core.issue.DefaultIssue;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
-import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
@@ -45,7 +45,7 @@ public class TestErrorRuleTest {
   static RuleKey RULE_KEY = RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), CommonRuleKeys.FAILED_UNIT_TESTS);
 
   static ReportComponent FILE = ReportComponent.builder(Component.Type.FILE, 1)
-    .setFileAttributes(new FileAttributes(true, "java"))
+    .setFileAttributes(new FileAttributes(true, "java", 1))
     .setName("FooTest.java")
     .build();
 
index 53acf238294aef3a7e543720d496944165476b59..3ef1c1325a23eb8d954140078e42d6310fc7d920 100644 (file)
@@ -83,8 +83,8 @@ public class MaintainabilityMeasuresVisitorTest {
         .addChildren(
           builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
             .addChildren(
-              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file1").build(),
-              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file2").build())
+              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file1").build(),
+              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file2").build())
             .build())
         .build())
     .build();
@@ -147,7 +147,7 @@ public class MaintainabilityMeasuresVisitorTest {
                 createFileComponent(LANGUAGE_KEY_1, 1111),
                 createFileComponent(LANGUAGE_KEY_2, 1112),
                 // Unit test should not be ignored
-                builder(FILE, 1113).setFileAttributes(new FileAttributes(true, LANGUAGE_KEY_1)).build())
+                builder(FILE, 1113).setFileAttributes(new FileAttributes(true, LANGUAGE_KEY_1, 1)).build())
               .build(),
             builder(DIRECTORY, 112)
               .addChildren(
@@ -358,7 +358,7 @@ public class MaintainabilityMeasuresVisitorTest {
   }
 
   private static ReportComponent createFileComponent(String languageKey1, int fileRef) {
-    return builder(FILE, fileRef).setFileAttributes(new FileAttributes(false, languageKey1)).build();
+    return builder(FILE, fileRef).setFileAttributes(new FileAttributes(false, languageKey1, 1)).build();
   }
 
   private static Measure createMaintainabilityRatingMeasure(Rating rating) {
index d54cbeda58be7e66d78a045e6894d3a364cdd75b..a0fb67083e316b13791c87ba24d0f4bda8bfeca0 100644 (file)
@@ -145,7 +145,7 @@ public class NewMaintainabilityMeasuresVisitorTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY)).build())
+          builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
         .build());
     measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50, 12));
     measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
@@ -298,7 +298,7 @@ public class NewMaintainabilityMeasuresVisitorTest {
             .addChildren(
               builder(DIRECTORY, 111)
                 .addChildren(
-                  builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY)).build())
+                  builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
                 .build())
             .build())
         .build());
@@ -340,7 +340,7 @@ public class NewMaintainabilityMeasuresVisitorTest {
 
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
-        .addChildren(builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY)).build())
+        .addChildren(builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
         .build());
 
     Measure newDebtMeasure = newMeasureBuilder().setVariations(new MeasureVariations(500d, 500d, 500d, 120d, 120d)).createNoValue();
@@ -374,7 +374,7 @@ public class NewMaintainabilityMeasuresVisitorTest {
             .addChildren(
               builder(DIRECTORY, 111)
                 .addChildren(
-                  builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY)).build())
+                  builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
                 .build())
             .build())
         .build());
@@ -408,7 +408,7 @@ public class NewMaintainabilityMeasuresVisitorTest {
             .addChildren(
               builder(DIRECTORY, 111)
                 .addChildren(
-                  builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY)).build())
+                  builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
                 .build())
             .build())
         .build());
@@ -429,7 +429,7 @@ public class NewMaintainabilityMeasuresVisitorTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(isUnitTest == Flag.UT_FILE, LANGUAGE_1_KEY)).build())
+          builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(isUnitTest == Flag.UT_FILE, LANGUAGE_1_KEY, 1)).build())
         .build());
 
     Measure newDebtMeasure = createNewDebtMeasure(newDebtPeriod2, newDebtPeriod4);
index dce6308ddfcbd5bb3cd943d5824c3990dc6592d0..1d962c7d637fea6f85a0ed2fbea91ccb0a8593b3 100644 (file)
@@ -88,8 +88,8 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
         .addChildren(
           builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
             .addChildren(
-              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file1").build(),
-              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file2").build())
+              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file1").build(),
+              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file2").build())
             .build())
         .build())
     .build();
index 8ba41fd91955a8d19c29f240c89168d4fa3a9262..8265141fa061ba3f8f4c25d8b0dfa91d6e8e6e50 100644 (file)
@@ -84,8 +84,8 @@ public class ReliabilityAndSecurityRatingMeasuresVisitorTest {
         .addChildren(
           builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
             .addChildren(
-              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file1").build(),
-              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1)).setKey("file2").build())
+              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file1").build(),
+              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file2").build())
             .build())
         .build())
     .build();
index bc3b215048c1a908ce9770d40d9f0fd371c24414..2afbc48248dccf444dff73942264b3b5f9e6c765 100644 (file)
@@ -24,11 +24,11 @@ import com.google.common.collect.Lists;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.measures.CoreMetrics;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.ViewsComponent;
 import org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler;
 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
@@ -232,6 +232,6 @@ public class LastCommitVisitorTest {
   }
 
   private ReportComponent createFileComponent(int fileRef) {
-    return ReportComponent.builder(FILE, fileRef).setFileAttributes(new FileAttributes(false, "js")).build();
+    return ReportComponent.builder(FILE, fileRef).setFileAttributes(new FileAttributes(false, "js", 1)).build();
   }
 }
index 31b21bd423378f7c6c451898715f51226aab73de..3185ba9ccbd28dfcfd5b2c0ec9aff575a9c8bea4 100644 (file)
@@ -338,7 +338,8 @@ public class BuildComponentTreeStepTest {
   private static ScannerReport.Component component(int componentRef, ComponentType componentType, @Nullable String key, @Nullable String path, int... children) {
     ScannerReport.Component.Builder builder = ScannerReport.Component.newBuilder()
       .setType(componentType)
-      .setRef(componentRef);
+      .setRef(componentRef)
+      .setLines(1);
     if (key != null) {
       builder.setKey(key);
     }
index afe20a5db7adc8fb7e16109a4d6a851d1b9181e4..7e343fd64d6fe1184bc2586e43ad538d9e232431 100644 (file)
@@ -74,13 +74,13 @@ public class ComputeQProfileMeasureStepTest {
           ReportComponent.builder(MODULE, SUB_MODULE_REF)
             .addChildren(ReportComponent.builder(DIRECTORY, FOLDER_1_REF)
               .addChildren(
-                ReportComponent.builder(FILE, FILE_1_1_REF).setFileAttributes(new FileAttributes(false, "java")).build(),
-                ReportComponent.builder(FILE, FILE_1_2_REF).setFileAttributes(new FileAttributes(false, "java")).build())
+                ReportComponent.builder(FILE, FILE_1_1_REF).setFileAttributes(new FileAttributes(false, "java", 1)).build(),
+                ReportComponent.builder(FILE, FILE_1_2_REF).setFileAttributes(new FileAttributes(false, "java", 1)).build())
               .build(),
               ReportComponent.builder(DIRECTORY, FOLDER_2_REF)
                 .addChildren(
-                  ReportComponent.builder(FILE, FILE_2_1_REF).setFileAttributes(new FileAttributes(false, null)).build(),
-                  ReportComponent.builder(FILE, FILE_2_2_REF).setFileAttributes(new FileAttributes(false, "php")).build())
+                  ReportComponent.builder(FILE, FILE_2_1_REF).setFileAttributes(new FileAttributes(false, null, 1)).build(),
+                  ReportComponent.builder(FILE, FILE_2_2_REF).setFileAttributes(new FileAttributes(false, "php", 1)).build())
                 .build())
             .build())
         .build())
index e2ba981ab2fa9a4b379b8d8b7d920d779d8caa39..e45b7e4af4ace3f1017521b7089bb1dd810c06eb 100644 (file)
@@ -42,16 +42,16 @@ import org.sonar.db.duplication.DuplicationUnitDto;
 import org.sonar.duplications.block.Block;
 import org.sonar.duplications.block.ByteArray;
 import org.sonar.scanner.protocol.output.ScannerReport;
+import org.sonar.server.computation.task.projectanalysis.analysis.Analysis;
 import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.duplication.CrossProjectDuplicationStatusHolder;
 import org.sonar.server.computation.task.projectanalysis.duplication.IntegrateCrossProjectDuplications;
 import org.sonar.server.computation.task.step.ComputationStep;
-import org.sonar.server.computation.task.projectanalysis.analysis.Analysis;
 
 import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -76,7 +76,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
 
   static final Component CURRENT_FILE = ReportComponent.builder(FILE, FILE_REF)
     .setKey(CURRENT_FILE_KEY)
-    .setFileAttributes(new FileAttributes(false, XOO_LANGUAGE))
+    .setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1))
     .build();
 
   @Rule
index f23b3e4bf23fc68a6b7f4f35580a4e8928f47eed..3f0cb7fc1decfcee98c7bcde568b7ba68d963404 100644 (file)
@@ -35,10 +35,10 @@ import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.CoverageDetail;
 import org.sonar.scanner.protocol.output.ScannerReport.Test.TestStatus;
 import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.step.ComputationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -87,8 +87,8 @@ public class PersistTestsStepTest extends BaseStepTest {
 
     root = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(
       ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE_UUID").setKey("MODULE_KEY").addChildren(
-        ReportComponent.builder(Component.Type.FILE, 3).setUuid(TEST_FILE_UUID_1).setKey("TEST_FILE1_KEY").setFileAttributes(new FileAttributes(true, null)).build(),
-        ReportComponent.builder(Component.Type.FILE, 4).setUuid(TEST_FILE_UUID_2).setKey("TEST_FILE2_KEY").setFileAttributes(new FileAttributes(true, null)).build(),
+        ReportComponent.builder(Component.Type.FILE, 3).setUuid(TEST_FILE_UUID_1).setKey("TEST_FILE1_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(),
+        ReportComponent.builder(Component.Type.FILE, 4).setUuid(TEST_FILE_UUID_2).setKey("TEST_FILE2_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(),
         ReportComponent.builder(Component.Type.FILE, 5).setUuid(MAIN_FILE_UUID_1).setKey("MAIN_FILE1_KEY").build(),
         ReportComponent.builder(Component.Type.FILE, 6).setUuid(MAIN_FILE_UUID_2).setKey("MAIN_FILE2_KEY").build()).build())
       .build();
index 1b076aa63a7433d9c4adb3896f71bdb0175bd2bf..09e3c1a7d26dbb56e5e33c5ef5740c773fe734ab 100644 (file)
@@ -78,7 +78,7 @@ public class ReportCoverageMeasuresStepTest {
                   builder(DIRECTORY, DIRECTORY_REF)
                     .addChildren(
                       builder(FILE, FILE_1_REF).build(),
-                      builder(FILE, UNIT_TEST_FILE_REF).setFileAttributes(new FileAttributes(true, "some language")).build(),
+                      builder(FILE, UNIT_TEST_FILE_REF).setFileAttributes(new FileAttributes(true, "some language", 1)).build(),
                       builder(FILE, FILE_2_REF).build())
                     .build())
                 .build())
index d07c3ac89937b85467e833ffef8114c7b31d2e3a..b689a252b89512f6ce72939ebf0b0b224a471775 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.server.computation.task.projectanalysis.step;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
 import org.sonar.server.computation.task.step.ComputationStep;
@@ -79,10 +79,10 @@ public class ReportLanguageDistributionMeasuresStepTest {
                 .addChildren(
                   builder(DIRECTORY, DIRECTORY_REF)
                     .addChildren(
-                      builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE)).build(),
-                      builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE)).build(),
-                      builder(FILE, FILE_3_REF).setFileAttributes(new FileAttributes(false, JAVA_LANGUAGE)).build(),
-                      builder(FILE, FILE_4_REF).setFileAttributes(new FileAttributes(false, null)).build())
+                      builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1)).build(),
+                      builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1)).build(),
+                      builder(FILE, FILE_3_REF).setFileAttributes(new FileAttributes(false, JAVA_LANGUAGE, 1)).build(),
+                      builder(FILE, FILE_4_REF).setFileAttributes(new FileAttributes(false, null, 1)).build())
                     .build())
                 .build())
             .build())
index aa09a74d46fc61a54027e4144bba9f6045a9b523..e2e75ae45c9f43f1831379be54ee0206c42f9e80 100644 (file)
@@ -113,7 +113,7 @@ public class ReportNewCoverageMeasuresStepTest {
 
   private NewCoverageMeasuresStep underTest = new NewCoverageMeasuresStep(treeRootHolder, periodsHolder, measureRepository, metricRepository, scmInfoRepository);
   public static final ReportComponent FILE_COMPONENT = ReportComponent.builder(Component.Type.FILE, FILE_1_REF)
-    .setFileAttributes(new FileAttributes(false, null)).build();
+    .setFileAttributes(new FileAttributes(false, null, 1)).build();
 
   @Before
   public void setUp() {
@@ -151,7 +151,7 @@ public class ReportNewCoverageMeasuresStepTest {
 
   @Test
   public void no_measure_for_unit_test_FILE_component() {
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null)).build());
+    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null, 1)).build());
 
     underTest.execute();
 
@@ -160,7 +160,7 @@ public class ReportNewCoverageMeasuresStepTest {
 
   @Test
   public void no_measures_for_FILE_component_without_code() {
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, null)).build());
+    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, null, 1)).build());
 
     underTest.execute();
 
index ecb1ec7253ea022b62c29595bd5728f32556d77a..f3aae8bc576d5c74af571d3f64176f18ffd48c02 100644 (file)
@@ -92,7 +92,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   public void persist_components() {
     Component file = builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
       .setPath("src/main/java/dir/Foo.java")
-      .setFileAttributes(new FileAttributes(false, "java"))
+      .setFileAttributes(new FileAttributes(false, "java", 1))
       .build();
     Component directory = builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
       .setPath("src/main/java/dir")
@@ -216,7 +216,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
             .addChildren(
               builder(FILE, 3).setUuid("DEFG").setKey(PROJECT_KEY + ":src/test/java/dir/FooTest.java")
                 .setPath("src/test/java/dir/FooTest.java")
-                .setFileAttributes(new FileAttributes(true, null))
+                .setFileAttributes(new FileAttributes(true, null, 1))
                 .build())
             .build())
         .build());
index a6f08ac2361a4e342b42bc613cbd1401b417b8f1..1317341dd7c08f2ab7c80230abb28ed5f4d8fb45 100644 (file)
@@ -23,8 +23,8 @@ import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.measures.CoreMetrics;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepoEntry;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
@@ -83,11 +83,11 @@ public class ReportSizeMeasuresStepTest {
                 builder(DIRECTORY, DIRECTORY_2_REF)
                   .addChildren(
                     builder(FILE, FILE_3_REF).build(),
-                    builder(FILE, UNIT_TEST_1_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE)).build())
+                    builder(FILE, UNIT_TEST_1_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE, 1)).build())
                   .build(),
                 builder(DIRECTORY, DIRECTORY_3_REF)
                   .addChildren(
-                    builder(FILE, UNIT_TEST_2_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE)).build())
+                    builder(FILE, UNIT_TEST_2_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE, 1)).build())
                   .build())
               .build())
           .build())
index 7260260f283a0cfd7f6e531b620c33f453732e59..59206e1d52068a9931814f60e78562f4f2e1ada8 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.server.computation.task.projectanalysis.step;
 import org.assertj.core.data.Offset;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
 import org.sonar.server.computation.task.step.ComputationStep;
@@ -73,8 +73,8 @@ public class ReportUnitTestMeasuresStepTest {
                 .addChildren(
                   builder(DIRECTORY, DIRECTORY_REF)
                     .addChildren(
-                      builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null)).build(),
-                      builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(true, null)).build())
+                      builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null, 1)).build(),
+                      builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(true, null, 1)).build())
                     .build())
                 .build())
             .build())
index 01a9cc7ead8e4cc16a718181ea0f3f31b06bfc90..0bfdff21c152e3dfc20a59816fb1d40c833c1a2f 100644 (file)
@@ -86,7 +86,7 @@ message Component {
   // Only available on PROJECT and MODULE types
   // TODO rename this property -> moduleKey ?
   string key = 10;
-  // Only available on FILE type
+  // Only available on FILE type, should always be at least 1
   int32 lines = 11;
   // Only available on PROJECT and MODULE types
   string description = 12;