From ae11811f8191818b894707223c37bf27f7b9b729 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 30 Sep 2016 15:34:26 -0700 Subject: [PATCH] Revert "Fix the `cpplint.py` `build/endif_comment` check." --- cpplint/cpplint.py | 9 ++++----- cpplint/cpplint_unittest.py | 29 ++++------------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/cpplint/cpplint.py b/cpplint/cpplint.py index 8d30ed6..3366b39 100755 --- a/cpplint/cpplint.py +++ b/cpplint/cpplint.py @@ -2710,11 +2710,6 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, filename, line number, error level, and message """ - line = clean_lines.lines_without_raw_strings[linenum] - if Match(r'\s*#\s*endif\s*([^/\s]|/[^/]|$)', line): - error(filename, linenum, 'build/endif_comment', 5, - 'Uncommented text after #endif is non-standard. Use a comment.') - # Remove comments from the line, but leave in strings for now. line = clean_lines.lines[linenum] @@ -2745,6 +2740,10 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, 'Storage-class specifier (static, extern, typedef, etc) should be ' 'at the beginning of the declaration.') + if Match(r'\s*#\s*endif\s*[^/\s]+', line): + error(filename, linenum, 'build/endif_comment', 5, + 'Uncommented text after #endif is non-standard. Use a comment.') + if Match(r'\s*class\s+(\w+\s*::\s*)+\w+\s*;', line): error(filename, linenum, 'build/forward_decl', 5, 'Inner-style forward declarations are invalid. Remove this line.') diff --git a/cpplint/cpplint_unittest.py b/cpplint/cpplint_unittest.py index 638bbc2..b8b8319 100755 --- a/cpplint/cpplint_unittest.py +++ b/cpplint/cpplint_unittest.py @@ -3754,7 +3754,7 @@ class CpplintTest(CpplintTestBase): #else baz; qux; - #endif // foo""", + #endif""", '') self.TestMultiLineLint( """void F() { @@ -3920,7 +3920,7 @@ class CpplintTest(CpplintTestBase): '#include "path/unique.h"', '#else', '#include "path/unique.h"', - '#endif // MACRO', + '#endif', ''], error_collector) self.assertEquals( @@ -3969,7 +3969,7 @@ class CpplintTest(CpplintTestBase): struct Foo : public Goo { #else struct Foo : public Hoo { - #endif // DERIVE_FROM_GOO + #endif };""", '') self.TestMultiLineLint( @@ -3979,7 +3979,7 @@ class CpplintTest(CpplintTestBase): : public Goo { #else : public Hoo { - #endif // DERIVE_FROM_GOO + #endif };""", '') # Test incomplete class @@ -3997,27 +3997,6 @@ class CpplintTest(CpplintTestBase): 'Uncommented text after #endif is non-standard. Use a comment.' ' [build/endif_comment] [5]') - correct_lines = [ - '#endif // text', - '#endif //' - ] - - for line in correct_lines: - self.TestLint(line, '') - - incorrect_lines = [ - '#endif', - '#endif Not a comment', - '#endif / One `/` is not enough to start a comment' - ] - - for line in incorrect_lines: - self.TestLint( - line, - 'Uncommented text after #endif is non-standard. Use a comment.' - ' [build/endif_comment] [5]') - - def testBuildForwardDecl(self): # The crosstool compiler we currently use will fail to compile the # code in this test, so we might consider removing the lint check.