diff mbox

[ovs-dev,v4,3/7] checkpatch: move the checks to the framework

Message ID 20170501201409.12116-4-aconole@redhat.com
State Accepted
Headers show

Commit Message

Aaron Conole May 1, 2017, 8:14 p.m. UTC
All of the checks are now part of the new 'check' framework.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 utilities/checkpatch.py | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

Comments

Ben Pfaff May 1, 2017, 8:27 p.m. UTC | #1
On Mon, May 01, 2017 at 04:14:05PM -0400, Aaron Conole wrote:
> All of the checks are now part of the new 'check' framework.
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  utilities/checkpatch.py | 41 ++++++++++++++++++++++++++---------------
>  1 file changed, 26 insertions(+), 15 deletions(-)
> 
> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
> index 30c0a3e..9d4e469 100755
> --- a/utilities/checkpatch.py
> +++ b/utilities/checkpatch.py
> @@ -177,7 +177,32 @@ checks = [
>       lambda x: not any([fmt in x for fmt in line_length_blacklist]),
>       'check': lambda x: line_length_check(x),
>       'print':
> -     lambda x: print_warning("Line is greater than 79-characters long", x)}
> +     lambda x: print_warning("Line is greater than 79-characters long", x)},
> +
> +    {'regex': '$(?<!\.mk)',
> +     'match_name': None,
> +     'check': lambda x: not leading_whitespace_is_spaces(x),
> +     'print':
> +     lambda(x): print_warning("Line has non-spaces leading whitespace", x)},

I changed this to "lambda x:" in my copy, to avoid a flake8 warning.
diff mbox

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 30c0a3e..9d4e469 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -177,7 +177,32 @@  checks = [
      lambda x: not any([fmt in x for fmt in line_length_blacklist]),
      'check': lambda x: line_length_check(x),
      'print':
-     lambda x: print_warning("Line is greater than 79-characters long", x)}
+     lambda x: print_warning("Line is greater than 79-characters long", x)},
+
+    {'regex': '$(?<!\.mk)',
+     'match_name': None,
+     'check': lambda x: not leading_whitespace_is_spaces(x),
+     'print':
+     lambda(x): print_warning("Line has non-spaces leading whitespace", x)},
+
+    {'regex': None, 'match_name': None,
+     'check': lambda x: trailing_whitespace_or_crlf(x),
+     'print': lambda x: print_warning("Line has trailing whitespace", x)},
+
+    {'regex': '(.c|.h)(.in)?$', 'match_name': None,
+     'check': lambda x: not if_and_for_whitespace_checks(x),
+     'print': lambda x: print_error("Improper whitespace around control block",
+                                    x)},
+
+    {'regex': '(.c|.h)(.in)?$', 'match_name': None,
+     'check': lambda x: not if_and_for_end_with_bracket_check(x),
+     'print': lambda x: print_error("Inappropriate bracing around statement",
+                                    x)},
+
+    {'regex': '(.c|.h)(.in)?$', 'match_name': None,
+     'check': lambda x: pointer_whitespace_check(x),
+     'print':
+     lambda x: print_error("Inappropriate spacing in pointer declaration", x)}
 ]
 
 
@@ -285,21 +310,7 @@  def ovs_checkpatch_parse(text):
             # linux or windows coding standards
             if '/datapath' in current_file:
                 continue
-            if (not current_file.endswith('.mk') and
-                    not leading_whitespace_is_spaces(cmp_line)):
-                print_warning("Line has non-spaces leading whitespace",
-                              lineno)
             run_checks(current_file, cmp_line, lineno)
-            if trailing_whitespace_or_crlf(cmp_line):
-                print_warning("Line has trailing whitespace", lineno)
-            if not if_and_for_whitespace_checks(cmp_line):
-                print_error("Improper whitespace around control block",
-                            lineno)
-            if not if_and_for_end_with_bracket_check(cmp_line):
-                print_error("Inappropriate bracing around statement", lineno)
-            if pointer_whitespace_check(cmp_line):
-                print_error("Inappropriate spacing in pointer declaration",
-                            lineno)
     if __errors or __warnings:
         return -1
     return 0