Пример #1
0
  @Test
  public void testCollectingSquidMetrics() {
    setUpSensor(TestUtils.loadResource("codechunks-project"), null);

    sensor.analyse(project, context);

    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.FILES), eq(1.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.LINES), eq(92.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.NCLOC), eq(54.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.STATEMENTS), eq(50.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.FUNCTIONS), eq(7.0));

    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.CLASSES), eq(0.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.COMPLEXITY), eq(19.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.COMMENT_LINES), eq(15.0));
  }
Пример #2
0
  @Test
  public void testBehaviourOnCircularIncludes() {
    // especially: when two files, both belonging to the set of
    // files to analyse, include each other, the preprocessor guards have to be disabled
    // and both have to be counted in terms of metrics
    setUpSensor(TestUtils.loadResource("circular-includes-project"), null);
    sensor.analyse(project, context);

    verify(context, times(2))
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.NCLOC), eq(1.0));
  }
Пример #3
0
  @Test
  public void testReplacingOfExtenalMacros() {
    settings.setProperty(CxxPlugin.DEFINES_KEY, "MACRO class A{};");
    setUpSensor(TestUtils.loadResource("external-macro-project"), null);

    sensor.analyse(project, context);

    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.FILES), eq(1.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.LINES), eq(2.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.NCLOC), eq(1.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.STATEMENTS), eq(0.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.FUNCTIONS), eq(0.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.CLASSES), eq(1.0));
  }
Пример #4
0
  @Test
  public void testFindingIncludedFiles() {
    settings.setProperty(CxxPlugin.INCLUDE_DIRECTORIES_KEY, "include");
    setUpSensor(TestUtils.loadResource("include-directories-project"), "src");

    sensor.analyse(project, context);

    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.FILES), eq(1.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.LINES), eq(27.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.NCLOC), eq(8.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.STATEMENTS), eq(0.0));
    verify(context)
        .saveMeasure(
            (org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.FUNCTIONS), eq(8.0));
    verify(context)
        .saveMeasure((org.sonar.api.resources.File) anyObject(), eq(CoreMetrics.CLASSES), eq(0.0));
  }