Examples of MeasureKey


Examples of ch.hortis.sonar.service.MeasureKey

  public Metrics getMetricKey() {
    return metricKey;
  }

  public void execute(Module module, List<Module> directSubmodules) {
    MeasureKey key = new MeasureKey(getMetric());
    if (module.getMeasure(key)==null) {
      double value = 0;
      boolean add = false;
      for(Module submodule:directSubmodules) {
        MetricMeasure submeasure = submodule.getMeasure(key);
        if (submeasure!=null) {
          value += submeasure.getValue();
          add = true;
        }
      }

      if (add) {
        if (log.isDebugEnabled()) log.debug( module.getMavenProject().getArtifactId() + " create " + key.getMetric() + ":" + value );
        module.createMeasure(key, value);
      }
    }
  }
View Full Code Here

Examples of ch.hortis.sonar.service.MeasureKey

    Map<MeasureKey, List<ProjectMeasure>> measuresByKey = getDatabaseService(ProjectMeasureService.class)
        .getHistory(module.getMavenProject(), metrics);

    for (Object o : measuresByKey.entrySet()) {
      Map.Entry entry = (Map.Entry) o;
      MeasureKey key = (MeasureKey) entry.getKey();
      List<ProjectMeasure> measures = (List<ProjectMeasure>) entry.getValue();
      List<Double> values = getValues(measures);
      TendencyAnalyser analyser = new TendencyAnalyser(values, MAX_DAYS);
      Number[] slopeAndLevel = getSlopeAndLevel(analyser, key.getMetric());
      if (slopeAndLevel[0] != null && slopeAndLevel[1]!=null) {
        module.createTendency(((MeasureKey) key.clone()), (Double) slopeAndLevel[0], (Integer) slopeAndLevel[1], MAX_DAYS);
      }
    }
  }
View Full Code Here

Examples of ch.hortis.sonar.service.MeasureKey

  public void execute(Module module, List<Module> directSubmodules) {
    Metric countMetric = getMetric(getCountMetric());

    for (MeasureKey key : module.getMeasureKeys()) {
      if (key.getMetric().equals(countMetric)) {
        MeasureKey linesKey = new MeasureKey(getMetric(Metrics.NCSS_NCSS), null, null, key.getFile());
        Double lines = module.getMeasureValue(linesKey);
        Double failuresCount = module.getMeasureValue(key);
        if ((lines != null) && (lines>0.0) && (failuresCount!=null)) {
          double index = getPercentage( failuresCount, lines, nbLinesForOneError);
          module.createMeasure(((MeasureKey)key.clone()).setMetric(getMetric()), index);
View Full Code Here

Examples of ch.hortis.sonar.service.MeasureKey

    processAtProjectLevel(module, directSubmodules);
    processAtFileLevel(module);
  }

  private void processAtProjectLevel(Module module, List<Module> directSubmodules) {
    MeasureKey ccKey = new MeasureKey(codeCoverage);
    if (module.getMeasure(ccKey) == null) {
      MeasureKey linesKey = new MeasureKey(getMetric(Metrics.NCSS_NCSS));
      Double cc = getPreferredCodeCoverage(module, null);
      if (cc == null) {
        // average of submodules
        double sum = 0.0;
        long lines = 0;
View Full Code Here

Examples of ch.hortis.sonar.service.MeasureKey

        ccFiles.add(ccFile);
      }
    }
    // now get the favorite measure for each file and create the measure
    for (File ccFile : ccFiles) {
      MeasureKey ccFileKey = new MeasureKey(codeCoverage, null, null, ccFile);
      Double ccValue = getPreferredCodeCoverage(module, ccFile);
      if ( ccValue != null ) {
        module.createMeasure(ccFileKey, ccValue);
      }
    }
View Full Code Here

Examples of ch.hortis.sonar.service.MeasureKey

      }
    }
  }

  protected Double getPreferredCodeCoverage(Module module, File file) {
    MeasureKey measureKey = new MeasureKey(cloverCoverage, null, null, file);
    Double cc = module.getMeasureValue(measureKey);
    if (cc == null) {
      measureKey = new MeasureKey(coberturaLineCoverage, null, null, file);
      cc = module.getMeasureValue(measureKey);
      if (cc == null) {
        measureKey = new MeasureKey(coberturaBranchCoverage, null, null, file);
        cc = module.getMeasureValue(measureKey);
      }
    }
    return cc;
  }
View Full Code Here

Examples of ch.hortis.sonar.service.MeasureKey

          }
        }
      }     
    }
   
    MeasureKey linesKey = new MeasureKey(getMetric(Metrics.NCSS_NCSS));
    Double lines = module.getMeasureValue(linesKey);

    for(Entry<RulesCategory, Double> entry : keys.entrySet()) {
      RulesCategory rulesCat = entry.getKey();
      Double value = entry.getValue();
      if ((lines != null) && (lines>0.0) && (value!=null)) {
        double index = getPercentage(value, lines, getNbLinesOfOneError());
        if (rulesCat == null) {
          module.createMeasure(new MeasureKey(getMetric()), index);
        } else {
          module.createMeasure(new MeasureKey(getMetric(), rulesCat, null), index);
        }       
      }
    }     
  }
View Full Code Here

Examples of org.sonar.core.measure.db.MeasureKey

    ComponentDto componentDto = new ComponentDto().setId(10L);
    when(componentDao.getNullableByKey(session, componentKey)).thenReturn(componentDto);

    String data = "{duplications}";
    MeasureKey measureKey = MeasureKey.of(componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY);
    when(measureDao.getNullableByKey(session, measureKey)).thenReturn(
      MeasureDto.createFor(measureKey).setTextValue("{duplications}")
    );

    List<DuplicationsParser.Block> blocks = newArrayList(new DuplicationsParser.Block(newArrayList(new DuplicationsParser.Duplication(componentDto, 1, 2))));
View Full Code Here

Examples of org.sonar.core.measure.db.MeasureKey

    MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, "org.codehaus.sonar:sonar", componentKey);

    ComponentDto componentDto = new ComponentDto().setId(10L);
    when(componentDao.getNullableByKey(session, componentKey)).thenReturn(componentDto);

    MeasureKey measureKey = MeasureKey.of(componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY);
    when(measureDao.getNullableByKey(session, measureKey)).thenReturn(null);

    WsTester.TestRequest request = tester.newGetRequest("api/duplications", "show").setParam("key", componentKey);
    request.execute();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.