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

Commit

Permalink
The cpplint returns non-zero when there is at least one message. If t…
Browse files Browse the repository at this point in the history
…he cpplint

is started from a make file, the non-zero return value will stop.

Proposal is to add "--return=value" option that forces the script return the
given value even when there is messages (see PC-lint -zero).

Attached batch adds the option to the cpplint and it has been tested with cmake
+ Visual Studio 2013.

Based on google/styleguide#28 by [email protected]
  • Loading branch information
tkruse committed Apr 24, 2016
1 parent a7c23c5 commit a29ec84
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
_USAGE = """
Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
[--counting=total|toplevel|detailed] [--root=subdir]
[--linelength=digits]
[--linelength=digits] [--return=return value]
<file> [file] ...
The style guidelines this tries to follow are those in
Expand Down Expand Up @@ -139,6 +139,14 @@
Examples:
--extensions=hpp,cpp
return=return value
The return value of the script is forced to given value for
preventing make files to stop too early.
Examples:
--return=0
cpplint.py supports per-directory configurations specified in CPPLINT.cfg
files. CPPLINT.cfg file can contain a number of key=value pairs.
Currently the following options are supported:
Expand Down Expand Up @@ -525,6 +533,10 @@ def u(x):
itervalues = dict.values
iteritems = dict.items

# The forces return value of the script to given value if defined.
# This is set by --return flag.
_return = None

def ParseNolintSuppressions(filename, raw_line, linenum, error):
"""Updates the global list of error-suppressions.
Expand Down Expand Up @@ -6282,7 +6294,8 @@ def ParseArguments(args):
'filter=',
'root=',
'linelength=',
'extensions='])
'extensions=',
'return='])
except getopt.GetoptError:
PrintUsage('Invalid arguments.')

Expand Down Expand Up @@ -6322,8 +6335,13 @@ def ParseArguments(args):
try:
_valid_extensions = set(val.split(','))
except ValueError:
PrintUsage('Extensions must be comma seperated list.')

PrintUsage('Extensions must be comma separated list.')
elif opt == '--return':
global _return
try:
_return = int(val)
except ValueError:
PrintUsage('Return value shall be integer.')
if not filenames:
PrintUsage('No files were specified.')

Expand All @@ -6350,6 +6368,8 @@ def main():
finally:
sys.stderr = backup_err

if _return is not None:
sys.exit(_return)
sys.exit(_cpplint_state.error_count > 0)


Expand Down

0 comments on commit a29ec84

Please sign in to comment.