Пример #1
0
 protected int getLineNumber(DroolsFile resource, VerifierMessageBase base) {
   for (RuleDescr ruleDescr : resource.getPackageDescr().getRules()) {
     if (base.getFaulty() instanceof RuleComponent)
       if (((RuleComponent) base.getFaulty()).getRuleName().equals(ruleDescr.getName())) {
         return ruleDescr.getLine();
       }
   }
   return 1;
 }
Пример #2
0
 protected void saveViolations(DroolsFile resource, SensorContext context, VerifierReport report) {
   List<Violation> violations = new ArrayList<Violation>();
   for (Severity severity : Severity.values()) {
     Collection<VerifierMessageBase> messages = report.getBySeverity(severity);
     for (VerifierMessageBase base : messages) {
       Rule rule = findRule(base);
       // ignore violations from report, if rule not activated in Sonar
       if (rule != null) {
         if (context.getResource(resource) != null) {
           int line = getLineNumber(resource, base);
           Violation violation =
               Violation.create(rule, resource).setLineId(line).setMessage(base.getMessage());
           violations.add(violation);
         }
       }
     }
   }
   context.saveViolations(violations);
 }
Пример #3
0
 protected Rule findRule(VerifierMessageBase base) {
   return ruleFinder.findByKey(
       DroolsRuleRepository.REPOSITORY_KEY, "DROOLS_" + base.getMessageType());
 }
Пример #4
0
 public void add(VerifierMessageBase message) {
   messages.add(message);
   messagesBySeverity.put(message.getSeverity(), message);
 }