From 91a32c5e39d2c1e789e7fe63355bc2ec399f68db Mon Sep 17 00:00:00 2001 From: Jordan Bayles Date: Fri, 22 Feb 2019 21:28:17 +0000 Subject: [PATCH] CppLint changes for VSCode cpplint plugin This patch makes some changes to the cpplint.py script for integration with the VSCode cpplint plugin, available here: https://marketplace.visualstudio.com/items?itemName=mine.cpplint Specifically, the "--repository" and "--headers" options currently cause our version of cpplint to crash, when we should at worst ignore them. A minor messaging tweak outputting the contents of the GetoptError, to make debugging input argument bugs easier, is included Change-Id: Id78616f5e2fdecb7da650042f0658623477ef9cb Reviewed-on: https://chromium-review.googlesource.com/c/1481938 Reviewed-by: Edward Lesmes Commit-Queue: Jordan Bayles --- cpplint.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpplint.py b/cpplint.py index 8a85c9e48..04b99cbc4 100755 --- a/cpplint.py +++ b/cpplint.py @@ -6004,14 +6004,16 @@ def ParseArguments(args): """ try: (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', + 'headers=', # We understand but ignore headers. 'counting=', 'filter=', 'root=', 'linelength=', 'extensions=', - 'project_root=']) - except getopt.GetoptError: - PrintUsage('Invalid arguments.') + 'project_root=', + 'repository=']) + except getopt.GetoptError as e: + PrintUsage('Invalid arguments: {}'.format(e)) verbosity = _VerboseLevel() output_format = _OutputFormat() @@ -6038,7 +6040,7 @@ def ParseArguments(args): elif opt == '--root': global _root _root = val - elif opt == '--project_root': + elif opt == '--project_root' or opt == "--repository": global _project_root _project_root = val if not os.path.isabs(_project_root):