Patchwork [5,of,5] check-code: make 'missing whitespace in assignment' more aggressive

login
register
mail settings
Submitter Mads Kiilerich
Date Dec. 9, 2012, 10:52 p.m.
Message ID <df38b89785e718e946cb.1355093566@mk-desktop>
Download mbox | patch
Permalink /patch/33/
State Accepted
Commit e440a2c0d944de45f4f1939bdf0e5fecaee7d5c7
Headers show

Comments

Mads Kiilerich - Dec. 9, 2012, 10:52 p.m.
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1355092396 -3600
# Node ID df38b89785e718e946cbfad856e4e0c31ff424e9
# Parent  06058f2a945397d538cd056e9bc9101521042d6e
check-code: make 'missing whitespace in assignment' more aggressive

New warnings:

 >     a.b=ab
 missing whitespace in assignment
(the pattern did not accept '.' on the left hand side)

 >     a=a
 missing whitespace in assignment
(the right hand side pattern never matched a single character)

 >     a=a + 7
 missing whitespace in assignment
(the pattern only matched one character after the identifier following =)
Matt Mackall - Dec. 10, 2012, 8:44 p.m.
On Sun, 2012-12-09 at 23:52 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski at unity3d.com>
> # Date 1355092396 -3600
> # Node ID df38b89785e718e946cbfad856e4e0c31ff424e9
> # Parent  06058f2a945397d538cd056e9bc9101521042d6e
> check-code: make 'missing whitespace in assignment' more aggressive

These are queued for default, thanks. I've folded in the glob fix Matt
noted.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -135,7 +135,7 @@ 
     (r"[^_]_\('[^']+'\s*%", "don't use % inside _()"),
     (r'(\w|\)),\w', "missing whitespace after ,"),
     (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"),
-    (r'^\s+\w+=\w+[^,)\n]$', "missing whitespace in assignment"),
+    (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
     (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
      r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Python 2.4'),
     (r'(\s+)try:\n((?:\n|\1\s.*\n)*?)\1\s*yield\b.*?'