add NOLINT_NEXTLINE to suppress linter errors on nextline
authorJeff Donahue <jeff.donahue@gmail.com>
Tue, 25 Feb 2014 21:39:20 +0000 (13:39 -0800)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Wed, 26 Feb 2014 23:42:38 +0000 (15:42 -0800)
scripts/cpplint.py

index 696a506..c5b14bd 100755 (executable)
@@ -433,8 +433,8 @@ _MATCH_ASM = re.compile(r'^\s*(?:asm|_asm|__asm|__asm__)'
 
 _regexp_compile_cache = {}
 
-# Finds occurrences of NOLINT or NOLINT(...).
-_RE_SUPPRESSION = re.compile(r'\bNOLINT\b(\([^)]*\))?')
+# Finds occurrences of NOLINT[_NEXTLINE] or NOLINT[_NEXTLINE](...).
+_RE_SUPPRESSION = re.compile(r'\bNOLINT(_NEXTLINE)?\b(\([^)]*\))?')
 
 # {str, set(int)}: a map from error categories to sets of linenumbers
 # on which those errors are expected and should be suppressed.
@@ -468,7 +468,9 @@ def ParseNolintSuppressions(filename, raw_line, linenum, error):
   # FIXME(adonovan): "NOLINT(" is misparsed as NOLINT(*).
   matched = _RE_SUPPRESSION.search(raw_line)
   if matched:
-    category = matched.group(1)
+    if matched.group(1) == '_NEXTLINE':
+      linenum += 1
+    category = matched.group(2)
     if category in (None, '(*)'):  # => "suppress all"
       _error_suppressions.setdefault(None, set()).add(linenum)
     else: