Package org.sonar.api.batch.fs

Examples of org.sonar.api.batch.fs.InputFile


    assertThat(ComponentKeys.createEffectiveKey(project, dir)).isEqualTo("my_project:src/org/foo");

    Library library = new Library("junit:junit", "4.7");
    assertThat(ComponentKeys.createEffectiveKey(project, library)).isEqualTo("junit:junit");

    InputFile file = new DefaultInputFile("foo", "foo/Bar.php");
    assertThat(ComponentKeys.createEffectiveKey("my_project", file)).isEqualTo("my_project:foo/Bar.php");
  }
View Full Code Here


    }
    return null;
  }

  private long getDevelopmentCost(DecoratorContext context) {
    InputFile file = fs.inputFile(fs.predicates().hasRelativePath(context.getResource().getKey()));
    if (file != null) {
      String language = file.language();
      return getMeasureValue(context, sqaleRatingSettings.getSizeMetric(language, metrics)) * sqaleRatingSettings.getDevCost(language);
    } else {
      Collection<Measure> childrenMeasures = context.getChildrenMeasures(CoreMetrics.DEVELOPMENT_COST);
      Double sum = sum(childrenMeasures);
      return sum.longValue();
View Full Code Here

  @Override
  public Object get(Value value, Class clazz, CoderContext context) {
    String fromModuleKey = value.getString();
    String fromRelativePath = value.getString();
    InputFile from = inputPathCache.getFile(fromModuleKey, fromRelativePath);
    if (from == null) {
      throw new IllegalStateException("Unable to load InputFile " + fromModuleKey + ":" + fromRelativePath);
    }
    String toModuleKey = value.getString();
    String toRelativePath = value.getString();
    InputFile to = inputPathCache.getFile(toModuleKey, toRelativePath);
    if (to == null) {
      throw new IllegalStateException("Unable to load InputFile " + toModuleKey + ":" + toRelativePath);
    }
    int weight = value.getInt();
    return new DefaultDependency()
View Full Code Here

  @Override
  public Object get(Value value, Class clazz, CoderContext context) {
    String testModuleKey = value.getString();
    String testRelativePath = value.getString();
    InputFile testFile = inputPathCache.getFile(testModuleKey, testRelativePath);
    if (testFile == null) {
      throw new IllegalStateException("Unable to load InputFile " + testModuleKey + ":" + testRelativePath);
    }
    String name = value.getString();
    String mainModuleKey = value.getString();
    String mainRelativePath = value.getString();
    InputFile mainFile = inputPathCache.getFile(mainModuleKey, mainRelativePath);
    if (mainFile == null) {
      throw new IllegalStateException("Unable to load InputFile " + mainModuleKey + ":" + mainRelativePath);
    }
    int size = value.getInt();
    List<Integer> lines = new ArrayList<Integer>(size);
View Full Code Here

  @Override
  public Object get(Value value, Class clazz, CoderContext context) {
    String moduleKey = value.getString();
    String relativePath = value.getString();
    InputFile testFile = inputPathCache.getFile(moduleKey, relativePath);
    if (testFile == null) {
      throw new IllegalStateException("Unable to load InputFile " + moduleKey + ":" + relativePath);
    }
    String name = value.getString();
    String message = value.getString();
View Full Code Here

    assertThat(result.inputFiles()).hasSize(2);

    // 4 measures per file
    assertThat(result.measures()).hasSize(8);

    InputFile inputFile = result.inputFile("src/sample1.xoo");
    // One clone group
    List<DuplicationGroup> duplicationGroups = result.duplicationsFor(inputFile);
    assertThat(duplicationGroups).hasSize(1);

    DuplicationGroup cloneGroup = duplicationGroups.get(0);
View Full Code Here

  public void should_search_input_files() throws Exception {
    DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);

    File mainFile = temp.newFile();
    InputFile mainInput = new DeprecatedDefaultInputFile("foo", "Main.java").setFile(mainFile).setType(InputFile.Type.MAIN);
    InputFile testInput = new DeprecatedDefaultInputFile("foo", "Test.java").setFile(temp.newFile()).setType(InputFile.Type.TEST);
    when(moduleInputFileCache.inputFiles()).thenReturn(Lists.newArrayList(mainInput, testInput));

    fs.index();
    Iterable<InputFile> inputFiles = fs.inputFiles(fs.predicates().hasType(InputFile.Type.MAIN));
    assertThat(inputFiles).containsOnly(mainInput);
View Full Code Here

    assertThat(adaptor.newMeasure()).isNotNull();
  }

  @Test
  public void shouldFailIfUnknowMetric() {
    InputFile file = new DefaultInputFile("foo", "src/Foo.php");

    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Unknow metric with key: lines");

    adaptor.store(new DefaultMeasure()
View Full Code Here

      .withValue(10));
  }

  @Test
  public void shouldSaveFileMeasureToSensorContext() {
    InputFile file = new DefaultInputFile("foo", "src/Foo.php");

    ArgumentCaptor<org.sonar.api.measures.Measure> argumentCaptor = ArgumentCaptor.forClass(org.sonar.api.measures.Measure.class);
    when(sensorContext.saveMeasure(eq(file), argumentCaptor.capture())).thenReturn(null);

    adaptor.store(new DefaultMeasure()
View Full Code Here

  @Test
  public void shouldSetAppropriatePersistenceMode() {
    // Metric FUNCTION_COMPLEXITY_DISTRIBUTION is only persisted on directories.

    InputFile file = new DefaultInputFile("foo", "src/Foo.php");

    ArgumentCaptor<org.sonar.api.measures.Measure> argumentCaptor = ArgumentCaptor.forClass(org.sonar.api.measures.Measure.class);
    when(sensorContext.saveMeasure(eq(file), argumentCaptor.capture())).thenReturn(null);

    adaptor.store(new DefaultMeasure()
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.fs.InputFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.