From patchwork Thu Jan 9 14:52:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4, of, 6, V2] check-code: explain what to do when a check-code rule mismatches From: Simon Heimberg X-Patchwork-Id: 3284 Message-Id: <1093aa559157b9037531.1389279156@lapsi.heimberg.home> To: Mercurial-devel Cc: Pierre-Yves David Date: Thu, 09 Jan 2014 15:52:36 +0100 # HG changeset patch # User Simon Heimberg # Date 1389130184 -3600 # Tue Jan 07 22:29:44 2014 +0100 # Node ID 1093aa559157b90375312777bb04ff7eb18d8001 # Parent a48899b6ab2b0e03768344cdf323a318ab5596ee check-code: explain what to do when a check-code rule mismatches In the past several approaches were used when a check-code rule triggered without a good reason. Not all of them looked nice, some were even wrong. Suggest some good practices which should be used instead. diff -r a48899b6ab2b -r 1093aa559157 contrib/check-code.py --- a/contrib/check-code.py Tue Jan 07 22:29:39 2014 +0100 +++ b/contrib/check-code.py Tue Jan 07 22:29:44 2014 +0100 @@ -7,6 +7,18 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. +"""style and portability checker for Mercurial + +when a rule triggers wrong, do one of the following (prefer one from top): + * do the work-around the rule suggests + * doublecheck that it is a false match + * improve the rule pattern + * add an ignore pattern to the rule (3rd arg) which matches your good line + (you can append a short comment and match this, like: #re-raises, # no-py24) + * change the pattern to a warning and list the exception in test-check-code-hg + * ONLY use no--check-code for skipping entire files from external sources +""" + import re, glob, os, sys import keyword import optparse