Patchwork D2864: contrib: open a hole in the open().read() ban for open().close()

login
register
mail settings
Submitter phabricator
Date March 15, 2018, 12:53 p.m.
Message ID <4386e492c257173e408e28012b28fc2d@localhost.localdomain>
Download mbox | patch
Permalink /patch/29530/
State Not Applicable
Headers show

Comments

phabricator - March 15, 2018, 12:53 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1190449c807d: contrib: open a hole in the open().read() ban for open().close() (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2864?vs=7042&id=7059

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit
Cc: 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
@@ -319,9 +319,9 @@ 
      "use util.readfile() instead"),
     (r'[\s\(](open|file)\([^)]*\)\.write\(',
      "use util.writefile() instead"),
-    (r'^[\s\(]*(open(er)?|file)\([^)]*\)',
+    (r'^[\s\(]*(open(er)?|file)\([^)]*\)(?!\.close\(\))',
      "always assign an opened file to a variable, and close it afterwards"),
-    (r'[\s\(](open|file)\([^)]*\)\.',
+    (r'[\s\(](open|file)\([^)]*\)\.(?!close\(\))',
      "always assign an opened file to a variable, and close it afterwards"),
     (r'(?i)descend[e]nt', "the proper spelling is descendAnt"),
     (r'\.debug\(\_', "don't mark debug messages for translation"),