summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorDamien Nozay <damien.nozay@gmail.com>2014-01-14 11:38:49 -0800
committerDamien Nozay <damien.nozay@gmail.com>2014-01-14 11:38:49 -0800
commit63e524fe67ef9391dc37e5f1034c6d493e3ec008 (patch)
treefae0c5d6793a6f8df1255054ac982b019f87ca3a /utils.py
parentbaf09d25e4fe7ccb3bd49cab5d4a27c2cc97dcb4 (diff)
downloadpylint-63e524fe67ef9391dc37e5f1034c6d493e3ec008.tar.gz
fix error with message reports when custom checker uses old-style messages
when register_messages is called, it allows messages that are in the form of 2-tuples, which means a symbol is not necessary. however, when doing report_message_stats is called, it does not handle the case where there is no symbol. solution: when collecting message, use the message id as the key if the symbol is None. e.g. ``` Messages -------- +------------------+------------+ |message id |occurrences | +==================+============+ |missing-docstring |6 | +------------------+------------+ |W9901 |4 | +------------------+------------+ |invalid-name |1 | +------------------+------------+ ```
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/utils.py b/utils.py
index 59e22a5..a09be51 100644
--- a/utils.py
+++ b/utils.py
@@ -400,6 +400,8 @@ class MessagesHandlerMixIn(object):
"""
msg_info = self.check_message_id(msg_descr)
msgid = msg_info.msgid
+ # backward compatibility, message may not have a symbol
+ symbol = msg_info.symbol or msgid
# Fatal messages and reports are special, the node/scope distinction
# does not apply to them.
if msgid[0] not in _SCOPE_EXEMPT:
@@ -427,9 +429,9 @@ class MessagesHandlerMixIn(object):
self.stats[msg_cat] += 1
self.stats['by_module'][self.current_name][msg_cat] += 1
try:
- self.stats['by_msg'][msg_info.symbol] += 1
+ self.stats['by_msg'][symbol] += 1
except KeyError:
- self.stats['by_msg'][msg_info.symbol] = 1
+ self.stats['by_msg'][symbol] = 1
# expand message ?
msg = msg_info.msg
if args: