Skip to content

Commit fac897f

Browse files
authored
Merge pull request google#137 from piotr-semenov/semenovp_fixes
Bug-fix: NOLINT, NOLINTNEXTLINE has no effect for lines like "};".
2 parents 70d6b7d + af8c843 commit fac897f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

cpplint/cpplint.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,6 +3884,14 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error):
38843884
# outputting warnings for the matching closing brace, if there are
38853885
# nested blocks with trailing semicolons, we will get the error
38863886
# messages in reversed order.
3887+
3888+
# We need to check the line forward for NOLINT
3889+
raw_lines = clean_lines.raw_lines
3890+
ParseNolintSuppressions(filename, raw_lines[endlinenum-1], endlinenum-1,
3891+
error)
3892+
ParseNolintSuppressions(filename, raw_lines[endlinenum], endlinenum,
3893+
error)
3894+
38873895
error(filename, endlinenum, 'readability/braces', 4,
38883896
"You don't need a ; after a }")
38893897

cpplint/cpplint_unittest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,21 @@ def testErrorSuppression(self):
521521
''],
522522
error_collector)
523523
self.assertEquals('', error_collector.Results())
524+
# NOLINT, NOLINTNEXTLINE silences the readability/braces warning for "};".
525+
error_collector = ErrorCollector(self.assert_)
526+
cpplint.ProcessFileData('test.cc', 'cc',
527+
['// Copyright 2014 Your Company.',
528+
'for (int i = 0; i != 100; ++i) {',
529+
'\tstd::cout << i << std::endl;',
530+
'}; // NOLINT',
531+
'for (int i = 0; i != 100; ++i) {',
532+
'\tstd::cout << i << std::endl;',
533+
'// NOLINTNEXTLINE',
534+
'};',
535+
'// LINT_KERNEL_FILE',
536+
''],
537+
error_collector)
538+
self.assertEquals('', error_collector.Results())
524539

525540
# Test Variable Declarations.
526541
def testVariableDeclarations(self):

0 commit comments

Comments
 (0)