private static RuleViolation processRule()

in reporter/src/com/intellij/rt/coverage/verify/Verifier.java [54:89]


  private static RuleViolation processRule(final Rule rule) {
    final ProjectData projectData = ProjectDataLoader.load(rule.reportFile);
    final Map<Integer, BoundViolation> violations = new HashMap<Integer, BoundViolation>();
    final TargetProcessor processor = rule.target.createTargetProcessor();
    processor.process(projectData, new TargetProcessor.Consumer() {

      private BoundViolation getOrCreateViolation(int boundId) {
        BoundViolation violation = violations.get(boundId);
        if (violation == null) {
          violation = new BoundViolation(boundId);
          violations.put(boundId, violation);
        }
        return violation;
      }

      @Override
      public void consume(String name, CollectedCoverage coverage) {
        for (Bound bound : rule.bounds) {
          final BigDecimal value = bound.valueType.getValue(bound.counter.getCounter(coverage));
          if (value == null) continue;
          if (bound.min != null && value.compareTo(bound.min) < 0) {
            final BoundViolation violation = getOrCreateViolation(bound.id);
            violation.minViolations.add(new Violation(name, value));
          }

          if (bound.max != null && value.compareTo(bound.max) > 0) {
            final BoundViolation violation = getOrCreateViolation(bound.id);
            violation.maxViolations.add(new Violation(name, value));
          }
        }
      }
    });

    if (violations.isEmpty()) return null;
    return new RuleViolation(rule.id, new ArrayList<BoundViolation>(violations.values()));
  }