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

The cpplint returns non-zero when there is at least one message. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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