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

Commit f81d6c8

Browse files
ksoletkruse
authored andcommitted
The cpplint returns non-zero when there is at least one message. If the 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]
1 parent a7c23c5 commit f81d6c8

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

cpplint.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
_USAGE = """
6161
Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
6262
[--counting=total|toplevel|detailed] [--root=subdir]
63-
[--linelength=digits]
63+
[--linelength=digits] [--return=return value]
6464
<file> [file] ...
6565
6666
The style guidelines this tries to follow are those in
@@ -139,6 +139,14 @@
139139
Examples:
140140
--extensions=hpp,cpp
141141
142+
return=return value
143+
The return value of the script is forced to given value for
144+
preventing make files to stop too early.
145+
146+
Examples:
147+
--return=0
148+
149+
142150
cpplint.py supports per-directory configurations specified in CPPLINT.cfg
143151
files. CPPLINT.cfg file can contain a number of key=value pairs.
144152
Currently the following options are supported:
@@ -525,6 +533,10 @@ def u(x):
525533
itervalues = dict.values
526534
iteritems = dict.items
527535

536+
# The forces return value of the script to given value if defined.
537+
# This is set by --return flag.
538+
_return = None
539+
528540
def ParseNolintSuppressions(filename, raw_line, linenum, error):
529541
"""Updates the global list of error-suppressions.
530542
@@ -6282,7 +6294,8 @@ def ParseArguments(args):
62826294
'filter=',
62836295
'root=',
62846296
'linelength=',
6285-
'extensions='])
6297+
'extensions=',
6298+
'return='])
62866299
except getopt.GetoptError:
62876300
PrintUsage('Invalid arguments.')
62886301

@@ -6322,8 +6335,13 @@ def ParseArguments(args):
63226335
try:
63236336
_valid_extensions = set(val.split(','))
63246337
except ValueError:
6325-
PrintUsage('Extensions must be comma seperated list.')
6326-
6338+
PrintUsage('Extensions must be comma separated list.')
6339+
elif opt == '--return':
6340+
global _return
6341+
try:
6342+
_return = int(val)
6343+
except ValueError:
6344+
PrintUsage('Return value shall be integer.')
63276345
if not filenames:
63286346
PrintUsage('No files were specified.')
63296347

@@ -6350,6 +6368,8 @@ def main():
63506368
finally:
63516369
sys.stderr = backup_err
63526370

6371+
if _return is not None:
6372+
sys.exit(_return)
63536373
sys.exit(_cpplint_state.error_count > 0)
63546374

63556375

0 commit comments

Comments
 (0)