Patchwork [2,of,2,V2] check-code: add a rule to forbid "cp -r"

login
register
mail settings
Submitter Jun Wu
Date Nov. 30, 2016, 7:26 p.m.
Message ID <ff3e01283fa1843920ad.1480534004@x1c>
Download mbox | patch
Permalink /patch/17805/
State Accepted
Headers show

Comments

Jun Wu - Nov. 30, 2016, 7:26 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1480533784 0
#      Wed Nov 30 19:23:04 2016 +0000
# Node ID ff3e01283fa1843920ad63dc1ff7bc6b0a4dbccb
# Parent  830986c78bb9697057768d64c8556d1dc03c0674
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r ff3e01283fa1
check-code: add a rule to forbid "cp -r"

See the commit message of the previous patch for the reason. In short,
according to the current POSIX standard, "-r" is "removed", and "-R" is the
current standard way to do "copy file hierarchies".
Augie Fackler - Dec. 2, 2016, 8:52 p.m.
On Wed, Nov 30, 2016 at 07:26:44PM +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1480533784 0
> #      Wed Nov 30 19:23:04 2016 +0000
> # Node ID ff3e01283fa1843920ad63dc1ff7bc6b0a4dbccb
> # Parent  830986c78bb9697057768d64c8556d1dc03c0674
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r ff3e01283fa1
> check-code: add a rule to forbid "cp -r"
>
> See the commit message of the previous patch for the reason. In short,
> according to the current POSIX standard, "-r" is "removed", and "-R" is the
> current standard way to do "copy file hierarchies".

Nice work. Thanks much for citing the POSIX chapter and verse too,
because I would have had to go digging for that as "removal" of -r
seems hilarious to me.

Queued.

>
> diff --git a/contrib/check-code.py b/contrib/check-code.py
> --- a/contrib/check-code.py
> +++ b/contrib/check-code.py
> @@ -143,5 +143,6 @@ testpats = [
>      (r'\w =  +\w', "only one space after = allowed"),
>      (r'\bsed\b.*[^\\]\\n', "don't use 'sed ... \\n', use a \\ and a newline"),
> -    (r'env.*-u', "don't use 'env -u VAR', use 'unset VAR'")
> +    (r'env.*-u', "don't use 'env -u VAR', use 'unset VAR'"),
> +    (r'cp.* -r ', "don't use 'cp -r', use 'cp -R'"),
>    ],
>    # warnings
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/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
@@ -143,5 +143,6 @@  testpats = [
     (r'\w =  +\w', "only one space after = allowed"),
     (r'\bsed\b.*[^\\]\\n', "don't use 'sed ... \\n', use a \\ and a newline"),
-    (r'env.*-u', "don't use 'env -u VAR', use 'unset VAR'")
+    (r'env.*-u', "don't use 'env -u VAR', use 'unset VAR'"),
+    (r'cp.* -r ', "don't use 'cp -r', use 'cp -R'"),
   ],
   # warnings