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

login
register
mail settings
Submitter Augie Fackler
Date July 7, 2017, 7:17 p.m.
Message ID <8a0a2d7fd76b56e480b6.1499455026@imladris.local>
Download mbox | patch
Permalink /patch/22117/
State Accepted
Headers show

Comments

Augie Fackler - July 7, 2017, 7:17 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1499454671 14400
#      Fri Jul 07 15:11:11 2017 -0400
# Node ID 8a0a2d7fd76b56e480b667da437d9bf861111188
# Parent  0bb8da5f14431d5e648cd548c9512c48bd2d5b9c
check-code: prohibit `if False` antipattern
Sean Farley - July 7, 2017, 7:50 p.m.
Augie Fackler <raf@durin42.com> writes:

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

Sweet cleanup, dude! Queued!

Patch

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'),