[PATCH 3 of 3] check-code: prohibit `if False` antipattern

Augie Fackler raf at durin42.com
Fri Jul 7 15:17:06 EDT 2017


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1499454671 14400
#      Fri Jul 07 15:11:11 2017 -0400
# Node ID 8a0a2d7fd76b56e480b667da437d9bf861111188
# Parent  0bb8da5f14431d5e648cd548c9512c48bd2d5b9c
check-code: prohibit `if False` antipattern

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -301,6 +301,7 @@ pypats = [
      "comparison with singleton, use 'is' or 'is not' instead"),
     (r'^\s*(while|if) [01]:',
      "use True/False for constant Boolean expression"),
+    (r'^\s*if False(:| +and)', 'Remove code instead of using `if False`'),
     (r'(?:(?<!def)\s+|\()hasattr\(',
      'hasattr(foo, bar) is broken on py2, use util.safehasattr(foo, bar) '
      'instead', r'#.*hasattr-py3-only'),


More information about the Mercurial-devel mailing list