mirror of
https://github.com/tiennm99/styleguide.git
synced 2026-08-05 06:22:40 +00:00
Fix the build/endif_comment check.
- The check needs to be run before we remove comments, otherwise valid lines will be found as invalid. - A single character different from `/` after the spaces is enough to indicate an error. - Also catch errors when only one `/` is present. (For example `#endif / MY_FILE_H`.)
This commit is contained in:
committed by
Alexandre Rames
parent
6d3a7d8a22
commit
f558944179
Vendored
+5
-4
@@ -2683,6 +2683,11 @@ 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]
|
||||
|
||||
@@ -2713,10 +2718,6 @@ 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.')
|
||||
|
||||
Reference in New Issue
Block a user