Patchwork [4,of,4] check-code: enforce strict spacing around assignment

login
register
mail settings
Submitter timeless@mozdev.org
Date Jan. 5, 2016, 6:08 a.m.
Message ID <d79fdb59e716fdc331c6.1451974094@waste.org>
Download mbox | patch
Permalink /patch/12525/
State Accepted
Headers show

Comments

timeless@mozdev.org - Jan. 5, 2016, 6:08 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1451583719 0
#      Thu Dec 31 17:41:59 2015 +0000
# Node ID d79fdb59e716fdc331c609c146a21c2b72e2f5c1
# Parent  d4e2ca0825a567586a461f67b0190611190f9ceb
check-code: enforce strict spacing around assignment
Augie Fackler - Jan. 5, 2016, 5:23 p.m.
On Tue, Jan 05, 2016 at 12:08:14AM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1451583719 0
> #      Thu Dec 31 17:41:59 2015 +0000
> # Node ID d79fdb59e716fdc331c609c146a21c2b72e2f5c1
> # Parent  d4e2ca0825a567586a461f67b0190611190f9ceb
> check-code: enforce strict spacing around assignment

Queued these, many thanks!

>
> diff --git a/contrib/check-code.py b/contrib/check-code.py
> --- a/contrib/check-code.py
> +++ b/contrib/check-code.py
> @@ -127,6 +127,7 @@
>      (r'seq ', "don't use 'seq', use $TESTDIR/seq.py"),
>      (r'\butil\.Abort\b', "directly use error.Abort"),
>      (r'\|&', "don't use |&, use 2>&1"),
> +    (r'\w =  +\w', "only one space after = allowed"),
>    ],
>    # warnings
>    [
> @@ -220,6 +221,7 @@
>      (r'(\w|\)),\w', "missing whitespace after ,"),
>      (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"),
>      (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
> +    (r'\w\s=\s\s+\w', "gratuitous whitespace after ="),
>      (r'.{81}', "line too long"),
>      (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
>      (r'[^\n]\Z', "no trailing newline"),
> @@ -337,6 +339,7 @@
>      (r'\w+ (\+\+|--)', "use foo++, not foo ++"),
>      (r'\w,\w', "missing whitespace after ,"),
>      (r'^[^#]\w[+/*]\w', "missing whitespace in expression"),
> +    (r'\w\s=\s\s+\w', "gratuitous whitespace after ="),
>      (r'^#\s+\w', "use #foo, not # foo"),
>      (r'[^\n]\Z', "no trailing newline"),
>      (r'^\s*#import\b', "use only #include in standard C code"),
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -127,6 +127,7 @@ 
     (r'seq ', "don't use 'seq', use $TESTDIR/seq.py"),
     (r'\butil\.Abort\b', "directly use error.Abort"),
     (r'\|&', "don't use |&, use 2>&1"),
+    (r'\w =  +\w', "only one space after = allowed"),
   ],
   # warnings
   [
@@ -220,6 +221,7 @@ 
     (r'(\w|\)),\w', "missing whitespace after ,"),
     (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"),
     (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
+    (r'\w\s=\s\s+\w', "gratuitous whitespace after ="),
     (r'.{81}', "line too long"),
     (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
     (r'[^\n]\Z', "no trailing newline"),
@@ -337,6 +339,7 @@ 
     (r'\w+ (\+\+|--)', "use foo++, not foo ++"),
     (r'\w,\w', "missing whitespace after ,"),
     (r'^[^#]\w[+/*]\w', "missing whitespace in expression"),
+    (r'\w\s=\s\s+\w', "gratuitous whitespace after ="),
     (r'^#\s+\w', "use #foo, not # foo"),
     (r'[^\n]\Z', "no trailing newline"),
     (r'^\s*#import\b', "use only #include in standard C code"),