pylint
changeset 322:e00098ab5750
Let pylint exit code indicate result of checks
If _any_ messages are shown the exitcode will be set to 2.
(Exitcode 1 already indicates that no files were specified.)
This implements what is requested on https://www.logilab.net/elo/ticket/4691 .
The approach taken in this patch is however that any message is an error. If a
message shouldn't count as an error it should be disabled.
There is a risk that some tool tools which call pylint could interprete the
exit code as if _pylint_ failed, and not that pylint completed its job and
concluded that the checked _files_ failed.
Some smoketests fails with this change - how do I change them to accept exitcode 2?
| author | Mads Kiilerich <mads@kiilerich.com> |
|---|---|
| date | Wed, 28 Jan 2009 00:58:01 +0100 |
| parents | f781c03f833c |
| children | f5c0be445a7a |
| files | lint.py utils.py |
| diffstat | 2 files changed, 5 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/lint.py Wed Jan 28 08:56:38 2009 +0100 1.2 +++ b/lint.py Wed Jan 28 00:58:01 2009 +0100 1.3 @@ -254,6 +254,7 @@ 1.4 self.base_file = None 1.5 self.current_name = None 1.6 self.current_file = None 1.7 + self.msg_counter = None 1.8 self.stats = None 1.9 # init options 1.10 self.options = options + PyLinter.options 1.11 @@ -579,6 +580,7 @@ 1.12 1.13 def open(self): 1.14 """initialize counters""" 1.15 + self.msg_counter = 0 1.16 self.stats = { 'by_module' : {}, 1.17 'by_msg' : {}, 1.18 'statement' : 0 1.19 @@ -853,6 +855,8 @@ 1.20 else: 1.21 linter.check(args) 1.22 sys.path.pop(0) 1.23 + if self.linter.msg_counter: 1.24 + sys.exit(2) 1.25 1.26 def cb_rpython_mode(self, name, value): 1.27 from pylint.checkers.rpython import RPythonChecker
2.1 --- a/utils.py Wed Jan 28 08:56:38 2009 +0100 2.2 +++ b/utils.py Wed Jan 28 00:58:01 2009 +0100 2.3 @@ -234,6 +234,7 @@ 2.4 if not self.is_message_enabled(msg_id, line): 2.5 return 2.6 # update stats 2.7 + self.msg_counter += 1 2.8 msg_cat = MSG_TYPES[msg_id[0]] 2.9 self.stats[msg_cat] += 1 2.10 self.stats['by_module'][self.current_name][msg_cat] += 1
