Ejemplo n.º 1
0
 @Test
 public void shouldDetectEmptyFiles() {
   SourceFile file = (SourceFile) squid.search("org/foo/CommentedOutFile.java");
   assertThat(file.getCheckMessages().size(), is(1));
   CheckMessage message = file.getCheckMessages().iterator().next();
   assertThat(message.getLine(), nullValue());
   assertThat(message.getDefaultMessage(), is("This Java file is empty"));
 }
Ejemplo n.º 2
0
 @Override
 public void visitFile(SourceFile sourceFile) {
   for (Integer line : sourceFile.getNoSonarTagLines()) {
     CheckMessage message =
         new CheckMessage(
             this, "Is //NOSONAR used to exclude false-positive or to hide real quality flaw ?");
     message.setBypassExclusion(true);
     message.setLine(line);
     sourceFile.log(message);
   }
 }
Ejemplo n.º 3
0
 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);
     }
   }
 }