Skip to content
This repository was archived by the owner on Jul 13, 2019. It is now read-only.

Commit 46ce93e

Browse files
poccitkruse
authored andcommitted
Allow end-of-namespace lines that begin with whitespace. Without this change,
indented end-of-namespace lines (mostly due to nested namespaces) would still cause an error even if the appropriate change is made to the line. Example: namespace x { namespace y { // this is a nontrivial namespace according // to cpplint static const int nontrivial[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // end of namespace y is indented, so would // still cause an error! } // namespace y } // namespace x Based on google/styleguide#17 by [email protected]
1 parent f59a765 commit 46ce93e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cpplint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ def CheckEnd(self, filename, clean_lines, linenum, error):
21702170
# deciding what these nontrivial things are, so this check is
21712171
# triggered by namespace size only, which works most of the time.
21722172
if (linenum - self.starting_linenum < 10
2173-
and not Match(r'};*\s*(//|/\*).*\bnamespace\b', line)):
2173+
and not Match(r'\s*};*\s*(//|/\*).*\bnamespace\b', line)):
21742174
return
21752175

21762176
# Look for matching comment at end of namespace.
@@ -2187,15 +2187,15 @@ def CheckEnd(self, filename, clean_lines, linenum, error):
21872187
# expected namespace.
21882188
if self.name:
21892189
# Named namespace
2190-
if not Match((r'};*\s*(//|/\*).*\bnamespace\s+' + re.escape(self.name) +
2190+
if not Match((r'\s*};*\s*(//|/\*).*\bnamespace\s+' + re.escape(self.name) +
21912191
r'[\*/\.\\\s]*$'),
21922192
line):
21932193
error(filename, linenum, 'readability/namespace', 5,
21942194
'Namespace should be terminated with "// namespace %s"' %
21952195
self.name)
21962196
else:
21972197
# Anonymous namespace
2198-
if not Match(r'};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
2198+
if not Match(r'\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
21992199
# If "// namespace anonymous" or "// anonymous namespace (more text)",
22002200
# mention "// anonymous namespace" as an acceptable form
22012201
if Match(r'}.*\b(namespace anonymous|anonymous namespace)\b', line):

0 commit comments

Comments
 (0)