Esempio n. 1
0
 /**
  * Detect ignore situation
  *
  * @param startLine position of line
  * @param text file text
  * @param start line column
  * @return true is that need to be ignored
  */
 private boolean isIgnore(int startLine, FileText text, LineColumn start) {
   final LineColumn end;
   if (matcher.end() == 0) {
     end = text.lineColumn(0);
   } else {
     end = text.lineColumn(matcher.end() - 1);
   }
   final int startColumn = start.getColumn();
   final int endLine = end.getLine();
   final int endColumn = end.getColumn();
   boolean ignore = false;
   if (ignoreComments) {
     final FileContents theFileContents = getFileContents();
     ignore =
         theFileContents.hasIntersectionWithComment(startLine, startColumn, endLine, endColumn);
   }
   return ignore;
 }
Esempio n. 2
0
  /** Recursive method that finds the matches. */
  private void findMatch() {

    final boolean foundMatch = matcher.find();
    if (foundMatch) {
      final FileText text = getFileContents().getText();
      final LineColumn start = text.lineColumn(matcher.start());
      final int startLine = start.getLine();

      final boolean ignore = isIgnore(startLine, text, start);

      if (!ignore) {
        matchCount++;
        if (illegalPattern || checkForDuplicates && matchCount - 1 > duplicateLimit) {
          errorCount++;
          logMessage(startLine);
        }
      }
      if (canContinueValidation(ignore)) {
        findMatch();
      }
    } else if (!illegalPattern && matchCount == 0) {
      logMessage(0);
    }
  }