Ejemplo n.º 1
0
 public boolean match(SourceCode unit) {
   switch (operator) {
     case EQUALS:
       return NumberUtils.compare(unit.getDouble(metric), value) == 0;
     case GREATER_THAN:
       return unit.getDouble(metric) > value;
     case GREATER_THAN_EQUALS:
       return unit.getDouble(metric) >= value;
     case LESS_THAN_EQUALS:
       return unit.getDouble(metric) <= value;
     case LESS_THAN:
       return unit.getDouble(metric) < value;
     default:
       throw new IllegalStateException("The operator value '" + operator + "' is unknown.");
   }
 }
Ejemplo n.º 2
0
 private void saveFunctionsComplexityDistribution(File sonarFile, SourceFile squidFile) {
   Collection<SourceCode> squidFunctionsInFile =
       scanner
           .getIndex()
           .search(new QueryByParent(squidFile), new QueryByType(SourceFunction.class));
   RangeDistributionBuilder complexityDistribution =
       new RangeDistributionBuilder(
           CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, FUNCTIONS_DISTRIB_BOTTOM_LIMITS);
   for (SourceCode squidFunction : squidFunctionsInFile) {
     complexityDistribution.add(squidFunction.getDouble(FlexMetric.COMPLEXITY));
   }
   context.saveMeasure(
       sonarFile, complexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY));
 }