APISonar


org.sonar.squid.api.SourceFile.log

> org > sonar > squid > api > SourceFile > log
org APIs sonar APIs squid APIs api APIs SourceFile APIs log APIs

Example 1
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);
    }
  }
Example 2
public void leaveClass(AsmClass asmClass) {
    if (this.asmClass != null) {
      for (CheckMessage message : internalNames.values()) {
        SourceFile sourceFile = getSourceFile(asmClass);
        sourceFile.log(message);
      }
    }
  }
Example 3
public void leaveFile(DetailAST ast) {
    SourceFile sourceFile = (SourceFile) peekSourceCode();
    for (TextBlock comment : comments) {
      String[] lines = comment.getText();
      for (int i = 0; i < lines.length; i++) {
        if (codeRecognizer.isLineOfCode(lines[i])) {
          CheckMessage message = new CheckMessage(this, "This block of commented-out lines of code should be removed.");
          message.setLine(comment.getStartLineNo() + i);
          sourceFile.log(message);
          break;
        }
      }
    }
    comments = null;
  }
Example 4
public void visitFile(SourceFile file) {
    int loc = file.getInt(Metric.LINES_OF_CODE);
    if (loc == 0) {
      CheckMessage message = new CheckMessage(this, "This Java file is empty");
      file.log(message);
    }
  }
Example 5
public void visitToken(DetailAST ast) {
    if (AstUtils.findParent(ast, TokenTypes.LITERAL_SWITCH) == null) {
      CheckMessage message = new CheckMessage(this,
          "The 'break' branching statement prevents refactoring the source code to reduce the complexity.");
      message.setLine(ast.getLineNo());
      SourceFile sourceFile = peekSourceCode().getParent(SourceFile.class);
      sourceFile.log(message);
    }
  }
Example 6
public void visitMethod(AsmMethod asmMethod) {
    if ( !asmMethod.isUsed() && asmMethod.isPrivate() && !asmMethod.isDefaultConstructor() && !SerializableContract.methodMatch(asmMethod)) {
      CheckMessage message = new CheckMessage(this, "Private method '" + asmMethod.getName() + "(...)' is never used.");
      SourceMethod sourceMethod = getSourceMethod(asmMethod);
      if (sourceMethod != null) {
        message.setLine(sourceMethod.getStartAtLine());
      }
      SourceFile file = getSourceFile(asmClass);
      file.log(message);
    }
  }
Example 7
public void visitEdge(AsmEdge edge) {
    if (edge.getTo() instanceof AsmMethod) {
      AsmMethod targetMethod = (AsmMethod) edge.getTo();
      AsmClass targetClass = targetMethod.getParent();
      if ("java/io/File".equals(targetClass.getInternalName()) && "deleteOnExit()V".equals(targetMethod.getKey())) {
        SourceFile sourceFile = getSourceFile(asmClass);
        CheckMessage message = new CheckMessage(this, "Do not use method 'File#deleteOnExit()'.");
        message.setLine(edge.getSourceLineNumber());
        sourceFile.log(message);
      }
    }
  }