comparison contrib/check-code.py @ 34508:b521b3a79afd

test-check-code: fail new commits which use 'atexit' instead of 'ui.atexit' Callbacks registered with 'atexit' are sometimes not called (like when hg aborts and calls os._exit). On the other hand, callbacks registered with 'ui.atexit' are called in most cases. Therefore, encouraging the use of 'ui.atexit' by failing the test 'test-check-code.t' appropriately. Test Plan: Ran the test 'test-check-code.t' after importing 'atexit' in one of the py files and confirmed that the test fails. Differential Revision: https://phab.mercurial-scm.org/D961
author Saurabh Singh <singhsrb@fb.com>
date Thu, 05 Oct 2017 14:18:55 -0700
parents b332c01247d8
children 3e4b7861c1c5
comparison
equal deleted inserted replaced
34507:30ae924a9e00 34508:b521b3a79afd
343 (r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'), 343 (r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'),
344 # XXX only catch mutable arguments on the first line of the definition 344 # XXX only catch mutable arguments on the first line of the definition
345 (r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"), 345 (r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"),
346 (r'\butil\.Abort\b', "directly use error.Abort"), 346 (r'\butil\.Abort\b', "directly use error.Abort"),
347 (r'^@(\w*\.)?cachefunc', "module-level @cachefunc is risky, please avoid"), 347 (r'^@(\w*\.)?cachefunc', "module-level @cachefunc is risky, please avoid"),
348 (r'^import atexit', "don't use atexit, use ui.atexit"),
348 (r'^import Queue', "don't use Queue, use util.queue + util.empty"), 349 (r'^import Queue', "don't use Queue, use util.queue + util.empty"),
349 (r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"), 350 (r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"),
350 (r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"), 351 (r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"),
351 (r'^import SocketServer', "don't use SockerServer, use util.socketserver"), 352 (r'^import SocketServer', "don't use SockerServer, use util.socketserver"),
352 (r'^import urlparse', "don't use urlparse, use util.urlreq"), 353 (r'^import urlparse', "don't use urlparse, use util.urlreq"),