[code-quality] Adding new warnings?
Sylvain Thénault
sylvain.thenault at logilab.fr
Mon Jul 8 09:22:08 CEST 2013
On 07 juillet 21:06, Skip Montanaro wrote:
> > Aside from Marius's point about the typo, you also need to make sure it is
> > added to the @check_messages decorator.
>
> Thanks. I would never have guessed that. Looking in
> checkers/classes.py, I see 22 messages defined in the MSGS dict, but
> only two are mentioned, in a single use of the check_messages
> decorator. I must be missing something.
Well, the pb is that when some visit methods interact with each others, it's not
always that easy to properly decorate those methods: the idea of this decorator
is that when some message is disabled, you don't want to call the method at all to
speed up things, rather than simply not printing out the message. Wrt the classes
checkers, the pb is that visit method (visit_* / leave_*) are responsible to emit
messages but also to handle a shared state that is used by other methods, hence
may only be disabled if almost all messages for this checker are disabled.
So, if you don't mind this shared state, the best thing to do is to have your own
checker class. Also notice you may have several checker with the same name, eg
'classes'.
FYI, messages ids will probably disappear at some point in favor of the new symbolic
names which are much more readable and easier to remember.
--
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
CubicWeb, the semantic web framework: http://www.cubicweb.org
More information about the code-quality
mailing list