Skip to content

Commit

Permalink
Reapply patches
Browse files Browse the repository at this point in the history
Reapply parts of 2324287 that are still relevant.
  • Loading branch information
dirk-thomas authored and jacobperron committed Sep 20, 2021
1 parent 8f925b0 commit 1754c5f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ament_cpplint/ament_cpplint/cpplint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
Expand Down Expand Up @@ -69,7 +69,6 @@
# -- pylint: disable=redefined-builtin
xrange = range # Python 3


_USAGE = """
Syntax: cpplint.py [--verbose=#] [--output=emacs|eclipse|vs7|junit|sed|gsed]
[--filter=-x,+y,...]
Expand Down Expand Up @@ -1612,6 +1611,7 @@ def RepositoryName(self):
os.path.exists(os.path.join(current_dir, ".hg")) or
os.path.exists(os.path.join(current_dir, ".svn"))):
root_dir = current_dir
break
current_dir = os.path.dirname(current_dir)

if (os.path.exists(os.path.join(root_dir, ".git")) or
Expand Down Expand Up @@ -2845,7 +2845,7 @@ def CheckEnd(self, filename, clean_lines, linenum, error):
# deciding what these nontrivial things are, so this check is
# triggered by namespace size only, which works most of the time.
if (linenum - self.starting_linenum < 10
and not Match(r'^\s*};*\s*(//|/\*).*\bnamespace\b', line)):
and not Match(r'^\s*};*\s*(//).*\bnamespace\b', line)):
return

# Look for matching comment at end of namespace.
Expand All @@ -2862,7 +2862,7 @@ def CheckEnd(self, filename, clean_lines, linenum, error):
# expected namespace.
if self.name:
# Named namespace
if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' +
if not Match((r'^\s*};*\s*(//).*\bnamespace\s+' +
re.escape(self.name) + r'[\*/\.\\\s]*$'),
line):
error(filename, linenum, 'readability/namespace', 5,
Expand Down Expand Up @@ -5856,6 +5856,10 @@ def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error):
remainder):
return False

# Don't warn in C files about C-style casts
if os.path.splitext(filename)[1] in ['.c', '.h']:
return False

# At this point, all that should be left is actual casts.
error(filename, linenum, 'readability/casting', 4,
'Using C-style cast. Use %s<%s>(...) instead' %
Expand Down

0 comments on commit 1754c5f

Please sign in to comment.