private void saveViolations(File sonarFile, SourceFile squidFile) {
   Collection<CheckMessage> messages = squidFile.getCheckMessages();
   if (messages != null) {
     for (CheckMessage message : messages) {
       Violation violation =
           Violation.create(annotationCheckFactory.getActiveRule(message.getCheck()), sonarFile)
               .setLineId(message.getLine())
               .setMessage(message.getText(Locale.ENGLISH));
       context.saveViolation(violation);
     }
   }
 }
 private void createViolation(SMInputCursor violationsCursor, Rule currentRule)
     throws XMLStreamException {
   org.sonar.api.resources.File sonarFile =
       org.sonar.api.resources.File.fromIOFile(
           new File(violationsCursor.getAttrValue("Source")), project);
   if (context.isIndexed(sonarFile, false)) {
     Violation violation = Violation.create(currentRule, sonarFile);
     String lineNumber = violationsCursor.getAttrValue("LineNumber");
     if (lineNumber != null) {
       violation.setLineId(Integer.parseInt(lineNumber));
     }
     violation.setMessage(violationsCursor.collectDescendantText().trim());
     violation.setSeverity(currentRule.getSeverity());
     context.saveViolation(violation);
   } else {
     LOG.debug("Violation could not be saved, associated resource not indexed " + sonarFile);
   }
 }
 private void saveViolations(final Collection<Violation> violations, final SensorContext context) {
   for (final Violation violation : violations) {
     context.saveViolation(violation);
   }
 }