@@ 683-712 (lines=30) @@ | ||
680 | ||
681 | ||
682 | ||
683 | def ParseNolintSuppressions(filename, raw_line, linenum, error): |
|
684 | """Updates the global list of line error-suppressions. |
|
685 | ||
686 | Parses any NOLINT comments on the current line, updating the global |
|
687 | error_suppressions store. Reports an error if the NOLINT comment |
|
688 | was malformed. |
|
689 | ||
690 | Args: |
|
691 | filename: str, the name of the input file. |
|
692 | raw_line: str, the line of input text, with comments. |
|
693 | linenum: int, the number of the current line. |
|
694 | error: function, an error handler. |
|
695 | """ |
|
696 | matched = Search(r'\bNOLINT(NEXTLINE)?\b(\([^)]+\))?', raw_line) |
|
697 | if matched: |
|
698 | if matched.group(1): |
|
699 | suppressed_line = linenum + 1 |
|
700 | else: |
|
701 | suppressed_line = linenum |
|
702 | category = matched.group(2) |
|
703 | if category in (None, '(*)'): # => "suppress all" |
|
704 | _error_suppressions.setdefault(None, set()).add(suppressed_line) |
|
705 | else: |
|
706 | if category.startswith('(') and category.endswith(')'): |
|
707 | category = category[1:-1] |
|
708 | if category in _ERROR_CATEGORIES: |
|
709 | _error_suppressions.setdefault(category, set()).add(suppressed_line) |
|
710 | elif category not in _LEGACY_ERROR_CATEGORIES: |
|
711 | error(filename, linenum, 'readability/nolint', 5, |
|
712 | 'Unknown NOLINT error category: %s' % category) |
|
713 | ||
714 | ||
715 | def ProcessGlobalSuppresions(lines): |
@@ 683-712 (lines=30) @@ | ||
680 | ||
681 | ||
682 | ||
683 | def ParseNolintSuppressions(filename, raw_line, linenum, error): |
|
684 | """Updates the global list of line error-suppressions. |
|
685 | ||
686 | Parses any NOLINT comments on the current line, updating the global |
|
687 | error_suppressions store. Reports an error if the NOLINT comment |
|
688 | was malformed. |
|
689 | ||
690 | Args: |
|
691 | filename: str, the name of the input file. |
|
692 | raw_line: str, the line of input text, with comments. |
|
693 | linenum: int, the number of the current line. |
|
694 | error: function, an error handler. |
|
695 | """ |
|
696 | matched = Search(r'\bNOLINT(NEXTLINE)?\b(\([^)]+\))?', raw_line) |
|
697 | if matched: |
|
698 | if matched.group(1): |
|
699 | suppressed_line = linenum + 1 |
|
700 | else: |
|
701 | suppressed_line = linenum |
|
702 | category = matched.group(2) |
|
703 | if category in (None, '(*)'): # => "suppress all" |
|
704 | _error_suppressions.setdefault(None, set()).add(suppressed_line) |
|
705 | else: |
|
706 | if category.startswith('(') and category.endswith(')'): |
|
707 | category = category[1:-1] |
|
708 | if category in _ERROR_CATEGORIES: |
|
709 | _error_suppressions.setdefault(category, set()).add(suppressed_line) |
|
710 | elif category not in _LEGACY_ERROR_CATEGORIES: |
|
711 | error(filename, linenum, 'readability/nolint', 5, |
|
712 | 'Unknown NOLINT error category: %s' % category) |
|
713 | ||
714 | ||
715 | def ProcessGlobalSuppresions(lines): |