mirror of
https://github.com/google/styleguide.git
synced 2024-03-22 13:11:43 +08:00
Merge pull request #137 from piotr-semenov/semenovp_fixes
Bug-fix: NOLINT, NOLINTNEXTLINE has no effect for lines like "};".
This commit is contained in:
commit
fac897f9a9
8
cpplint/cpplint.py
vendored
8
cpplint/cpplint.py
vendored
|
@ -3884,6 +3884,14 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error):
|
||||||
# outputting warnings for the matching closing brace, if there are
|
# outputting warnings for the matching closing brace, if there are
|
||||||
# nested blocks with trailing semicolons, we will get the error
|
# nested blocks with trailing semicolons, we will get the error
|
||||||
# messages in reversed order.
|
# messages in reversed order.
|
||||||
|
|
||||||
|
# We need to check the line forward for NOLINT
|
||||||
|
raw_lines = clean_lines.raw_lines
|
||||||
|
ParseNolintSuppressions(filename, raw_lines[endlinenum-1], endlinenum-1,
|
||||||
|
error)
|
||||||
|
ParseNolintSuppressions(filename, raw_lines[endlinenum], endlinenum,
|
||||||
|
error)
|
||||||
|
|
||||||
error(filename, endlinenum, 'readability/braces', 4,
|
error(filename, endlinenum, 'readability/braces', 4,
|
||||||
"You don't need a ; after a }")
|
"You don't need a ; after a }")
|
||||||
|
|
||||||
|
|
|
@ -521,6 +521,21 @@ class CpplintTest(CpplintTestBase):
|
||||||
''],
|
''],
|
||||||
error_collector)
|
error_collector)
|
||||||
self.assertEquals('', error_collector.Results())
|
self.assertEquals('', error_collector.Results())
|
||||||
|
# NOLINT, NOLINTNEXTLINE silences the readability/braces warning for "};".
|
||||||
|
error_collector = ErrorCollector(self.assert_)
|
||||||
|
cpplint.ProcessFileData('test.cc', 'cc',
|
||||||
|
['// Copyright 2014 Your Company.',
|
||||||
|
'for (int i = 0; i != 100; ++i) {',
|
||||||
|
'\tstd::cout << i << std::endl;',
|
||||||
|
'}; // NOLINT',
|
||||||
|
'for (int i = 0; i != 100; ++i) {',
|
||||||
|
'\tstd::cout << i << std::endl;',
|
||||||
|
'// NOLINTNEXTLINE',
|
||||||
|
'};',
|
||||||
|
'// LINT_KERNEL_FILE',
|
||||||
|
''],
|
||||||
|
error_collector)
|
||||||
|
self.assertEquals('', error_collector.Results())
|
||||||
|
|
||||||
# Test Variable Declarations.
|
# Test Variable Declarations.
|
||||||
def testVariableDeclarations(self):
|
def testVariableDeclarations(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user