From a43b86297ddc3ce02f278936ae90c2cce009e1aa Mon Sep 17 00:00:00 2001 From: "Robert (Jamie) Munro" Date: Thu, 16 Feb 2017 16:36:33 +0000 Subject: [PATCH 1/5] Explore matching nested bracketed stuff --- scripts/cpplint.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/cpplint.py b/scripts/cpplint.py index 7fdc937ecf5..0020b299de9 100755 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -552,7 +552,9 @@ "Missing space before {": r's/\([^ ]\){/\1 {/', "Tab found, replace by spaces": r's/\t/ /', "Line ends in whitespace. Consider deleting these extra spaces.": r's/\s*$//', - #"Redundant blank line at the end of a code block should be deleted.": "d", # messes up line numbers for other errors. + # "Statement after an if should be on a new line": r's/^\(\s*\)if *\(([^()]*)\) *\(.*\)$/\1if\2\n\1 \3/', # Single layer of nested bracets + # "Statement after an if should be on a new line": r's/^\(\s*\)if *\((\([^()]\|([^()]*)\)*)\) *\(.*\)$/\1if\2\n\1 \4/', # Max 2 layers of nested bracets; messes up line numbers for other errors. + # "Redundant blank line at the end of a code block should be deleted.": "d", # messes up line numbers for other errors. } _regexp_compile_cache = {} From 4e6c7b2144c1659e34ae2dd98298bb2e676c7a5c Mon Sep 17 00:00:00 2001 From: "Robert (Jamie) Munro" Date: Mon, 20 Feb 2017 00:50:11 +0000 Subject: [PATCH 2/5] Fix ; after } errors --- scripts/cpplint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/cpplint.py b/scripts/cpplint.py index 0020b299de9..697ad401f78 100755 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -552,6 +552,7 @@ "Missing space before {": r's/\([^ ]\){/\1 {/', "Tab found, replace by spaces": r's/\t/ /', "Line ends in whitespace. Consider deleting these extra spaces.": r's/\s*$//', + "You don't need a ; after a }": r's/};/}/', # "Statement after an if should be on a new line": r's/^\(\s*\)if *\(([^()]*)\) *\(.*\)$/\1if\2\n\1 \3/', # Single layer of nested bracets # "Statement after an if should be on a new line": r's/^\(\s*\)if *\((\([^()]\|([^()]*)\)*)\) *\(.*\)$/\1if\2\n\1 \4/', # Max 2 layers of nested bracets; messes up line numbers for other errors. # "Redundant blank line at the end of a code block should be deleted.": "d", # messes up line numbers for other errors. From 89d259eb974234cba2e7a06fb0a8eb7b7a9db210 Mon Sep 17 00:00:00 2001 From: "Robert (Jamie) Munro" Date: Mon, 20 Feb 2017 11:01:20 +0000 Subject: [PATCH 3/5] Fix missing space after , errors --- scripts/cpplint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/cpplint.py b/scripts/cpplint.py index 697ad401f78..d6937b13ac5 100755 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -553,6 +553,7 @@ "Tab found, replace by spaces": r's/\t/ /', "Line ends in whitespace. Consider deleting these extra spaces.": r's/\s*$//', "You don't need a ; after a }": r's/};/}/', + "Missing space after ,": r's/,\([^ ]\)/, \1/', # "Statement after an if should be on a new line": r's/^\(\s*\)if *\(([^()]*)\) *\(.*\)$/\1if\2\n\1 \3/', # Single layer of nested bracets # "Statement after an if should be on a new line": r's/^\(\s*\)if *\((\([^()]\|([^()]*)\)*)\) *\(.*\)$/\1if\2\n\1 \4/', # Max 2 layers of nested bracets; messes up line numbers for other errors. # "Redundant blank line at the end of a code block should be deleted.": "d", # messes up line numbers for other errors. From ce6b2b4ec7727f0f45e78c585fec6a90a319181f Mon Sep 17 00:00:00 2001 From: "Robert (Jamie) Munro" Date: Mon, 20 Feb 2017 11:13:14 +0000 Subject: [PATCH 4/5] Replace tabs globally within the line --- scripts/cpplint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpplint.py b/scripts/cpplint.py index d6937b13ac5..002fc43dc85 100755 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -550,7 +550,7 @@ "Remove space before ( in switch (": "s/switch (/switch(/", "Should have a space between // and comment": 's/\/\//\/\/ /', "Missing space before {": r's/\([^ ]\){/\1 {/', - "Tab found, replace by spaces": r's/\t/ /', + "Tab found, replace by spaces": r's/\t/ /g', "Line ends in whitespace. Consider deleting these extra spaces.": r's/\s*$//', "You don't need a ; after a }": r's/};/}/', "Missing space after ,": r's/,\([^ ]\)/, \1/', From 0b11c4385fb2d8b79afe35ec41d019f9e2b8dd41 Mon Sep 17 00:00:00 2001 From: "Robert (Jamie) Munro" Date: Fri, 3 Mar 2017 10:22:19 +0000 Subject: [PATCH 5/5] Add space after comma globally within the line --- scripts/cpplint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpplint.py b/scripts/cpplint.py index 002fc43dc85..450e9b8f64c 100755 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -553,7 +553,7 @@ "Tab found, replace by spaces": r's/\t/ /g', "Line ends in whitespace. Consider deleting these extra spaces.": r's/\s*$//', "You don't need a ; after a }": r's/};/}/', - "Missing space after ,": r's/,\([^ ]\)/, \1/', + "Missing space after ,": r's/,\([^ ]\)/, \1/g', # "Statement after an if should be on a new line": r's/^\(\s*\)if *\(([^()]*)\) *\(.*\)$/\1if\2\n\1 \3/', # Single layer of nested bracets # "Statement after an if should be on a new line": r's/^\(\s*\)if *\((\([^()]\|([^()]*)\)*)\) *\(.*\)$/\1if\2\n\1 \4/', # Max 2 layers of nested bracets; messes up line numbers for other errors. # "Redundant blank line at the end of a code block should be deleted.": "d", # messes up line numbers for other errors.