Patchwork [1,of,3] check-code: do not warn on printf \\x or \\[1-9]

login
register
mail settings
Submitter Simon Heimberg
Date July 1, 2013, 5:03 a.m.
Message ID <4e41528b9b05e8bdb7f2.1372654991@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1773/
State Accepted
Commit ee07f9d142c9960b4d9c62b852a2d05b5be2681d
Delegated to: Kevin Bullock
Headers show

Comments

Simon Heimberg - July 1, 2013, 5:03 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1372654258 -7200
# Node ID 4e41528b9b05e8bdb7f2d5ded7a25e3f0833354b
# Parent  b70d8e78f7d0cc900c423d1fa56b4b0544ab4d8e
check-code: do not warn on printf \\x or \\[1-9]

When there is a double backslash the following char does not have any special
meaning. So do not warn on this.
Remove the now obsolete no-check-code statement. (It was used wrongly anyway, it
skipped checking the entire file.)

Patch

diff -r b70d8e78f7d0 -r 4e41528b9b05 contrib/check-code.py
--- a/contrib/check-code.py	Mon Jul 01 06:50:58 2013 +0200
+++ b/contrib/check-code.py	Mon Jul 01 06:50:58 2013 +0200
@@ -68,8 +68,8 @@ 
     (r'head -c', "don't use 'head -c', use 'dd'"),
     (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
     (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
-    (r'printf.*\\([1-9]|0\d)', "don't use 'printf \NNN', use Python"),
-    (r'printf.*\\x', "don't use printf \\x, use Python"),
+    (r'printf.*[^\\]\\([1-9]|0\d)', "don't use 'printf \NNN', use Python"),
+    (r'printf.*[^\\]\\x', "don't use printf \\x, use Python"),
     (r'\$\(.*\)', "don't use $(expr), use `expr`"),
     (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
     (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
diff -r b70d8e78f7d0 -r 4e41528b9b05 tests/test-subrepo-paths.t
--- a/tests/test-subrepo-paths.t	Mon Jul 01 06:50:58 2013 +0200
+++ b/tests/test-subrepo-paths.t	Mon Jul 01 06:50:58 2013 +0200
@@ -17,7 +17,7 @@ 
 hg debugsub with remapping
 
   $ echo '[subpaths]' >> .hg/hgrc
-  $ printf 'http://example.net/lib(.*) = C:\\libs\\\\1-lib\\\n' >> .hg/hgrc # no-check-code
+  $ printf 'http://example.net/lib(.*) = C:\\libs\\\\1-lib\\\n' >> .hg/hgrc
 
   $ hg debugsub
   path sub