Patchwork D610: check-code: forbid "\S" in egrep regular expression

login
register
mail settings
Submitter phabricator
Date Sept. 3, 2017, 2:20 p.m.
Message ID <e0a28bdb61587ebd53bc5145ddff5a01@localhost.localdomain>
Download mbox | patch
Permalink /patch/23635/
State Not Applicable
Headers show

Comments

phabricator - Sept. 3, 2017, 2:20 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG11499bad0359: check-code: forbid "\S" in egrep regular expression (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D610?vs=1567&id=1587

REVISION DETAIL
  https://phab.mercurial-scm.org/D610

AFFECTED FILES
  contrib/check-code.py
  tests/test-context-metadata.t

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-context-metadata.t b/tests/test-context-metadata.t
--- a/tests/test-context-metadata.t
+++ b/tests/test-context-metadata.t
@@ -36,7 +36,7 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     Changed
   
-  $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0' 2>&1 | egrep '^\S*Error'
+  $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0' 2>&1 | egrep '^RuntimeError'
   RuntimeError: can't reuse the manifest: its p1 doesn't match the new ctx p1
 
   $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'user=foo <foo@example.com>'
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -119,6 +119,7 @@ 
     (r'\[[^\]]+==', '[ foo == bar ] is a bashism, use [ foo = bar ] instead'),
     (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
      "use egrep for extended grep syntax"),
+    (r'(^|\|\s*)e?grep .*\\S', "don't use \\S in regular expression"),
     (r'(?<!!)/bin/', "don't use explicit paths for tools"),
     (r'#!.*/bash', "don't use bash in shebang, use sh"),
     (r'[^\n]\Z', "no trailing newline"),