diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | lint.py | 29 | ||||
-rw-r--r-- | test/smoketest.py | 7 | ||||
-rw-r--r-- | utils.py | 13 |
5 files changed, 31 insertions, 24 deletions
@@ -17,9 +17,8 @@ ChangeLog for PyLint * fix #6951: false positive with W0104 * fix #6949 * patches by Mads Kiilerich: - * implement #4691, with a new zero-status-cat option to control which - categories of message won't make pylint exits with a non zero return - status if any + * implement #4691, make pylint exits with a non zero return + status if any messages other then Information are issued * fix #3711, #5626 (name resolution bug w/ decorator and class members) * fix #6954 @@ -52,6 +52,7 @@ Contributors * Amaury Forgeot d'Arc: patch to check names imported from a module exists in the module * Benjamin Niemann: patch to allow block level enabling/disabling of messages +* Nathaniel Manista: suspcicious lambda checking * Wolfgang Grafen, Axel Muller, Fabio Zadrozny, Pierre Rouleau, Maarten ter Huurne, Mirko Friedenhagen (among others): bug reports, feedback, feature requests... @@ -234,13 +234,8 @@ This is used by the global evaluation report (R0004).'}), {'type' : 'csv', 'metavar': '<msg ids>', 'group': 'Messages control', 'help' : 'Disable the message(s) with the given id(s).'}), - - ('zero-status-cat', - {'type' : 'string', 'metavar': '<msg cats>', 'default': 'IRC', - 'group': 'Messages control', - 'help' : 'Messages in listed categories (IRCWEF) won\'t \ -make pylint exits with a non zero return status.'}), ) + option_groups = ( ('Messages control', 'Options controling analysis messages'), ('Reports', 'Options related to output formating and reporting'), @@ -260,7 +255,6 @@ make pylint exits with a non zero return status.'}), self.base_file = None self.current_name = None self.current_file = None - self.msg_counter = None self.stats = None # init options self.options = options + PyLinter.options @@ -586,7 +580,6 @@ make pylint exits with a non zero return status.'}), def open(self): """initialize counters""" - self.msg_counter = 0 self.stats = { 'by_module' : {}, 'by_msg' : {}, 'statement' : 0 @@ -825,8 +818,20 @@ There are 5 kind of message types : * (F) fatal, if an error occured which prevented pylint from doing further \ processing. ''') + linter.add_help_section('Output status code', ''' +Pylint should leave with following status code: + * 0 if everything went fine + * 1 if some fatal message issued + * 2 if some error message issued + * 4 if some warning message issued + * 8 if some refactor message issued + * 16 if some convention message issued + * 32 on usage error + +status 1 to 16 will be bit-ORed so you can know which different categories has +been issued by analysing pylint output status code + ''') # read configuration - #linter.load_provider_defaults() linter.disable_message('W0704') linter.read_config_file() # is there some additional plugins in the file configuration, in @@ -845,7 +850,7 @@ processing. args = linter.load_command_line_configuration(args) if not args: print linter.help() - sys.exit(1) + sys.exit(32) # insert current working directory to the python path to have a correct # behaviour sys.path.insert(0, os.getcwd()) @@ -862,9 +867,7 @@ processing. else: linter.check(args) sys.path.pop(0) - if self.linter.msg_counter: - sys.exit(2) - sys.exit(0) + sys.exit(self.linter.msg_status) def cb_rpython_mode(self, name, value): from pylint.checkers.rpython import RPythonChecker diff --git a/test/smoketest.py b/test/smoketest.py index a3e5446..74b77fe 100644 --- a/test/smoketest.py +++ b/test/smoketest.py @@ -25,7 +25,7 @@ HERE = abspath(dirname(__file__)) class RunTC(TestCase): - def _runtest(self, args, reporter=None, code=2): + def _runtest(self, args, reporter=None, code=20): try: sys.stderr = sys.stdout = stream = StringIO() try: @@ -63,9 +63,6 @@ class RunTC(TestCase): """make pylint checking itself""" self._runtest(['pylint.lint'], reporter=VSTextReporter(StringIO())) - def test_no_args(self): - self._runtest([], code=1) - def test_no_ext_file(self): self._runtest([join(HERE, 'input', 'noext')], code=0) @@ -88,7 +85,7 @@ class RunTC(TestCase): def test_error_missing_arguments(self): self._runtest([], reporter=HTMLReporter(StringIO()), - code=1) + code=32) if __name__ == '__main__': @@ -41,7 +41,14 @@ MSG_TYPES = { 'E' : 'error', 'F' : 'fatal' } - +MSG_TYPES_STATUS = { + 'I' : 0, + 'C' : 16, + 'R' : 8, + 'W' : 4, + 'E' : 2, + 'F' : 1 + } def sort_checkers(checkers): """return a list of enabled checker sorted by priority""" @@ -100,6 +107,7 @@ class MessagesHandlerMixIn: self._module_msgs_state = {} # None self._msg_cats_state = {} self._module_msg_cats_state = None + self.msg_status = 0 def register_messages(self, checker): """register a dictionary of messages @@ -241,8 +249,7 @@ class MessagesHandlerMixIn: return # update stats msg_cat = MSG_TYPES[msg_id[0]] - if msg_id[0] not in self.config.zero_status_cat: - self.msg_counter += 1 + self.msg_status ^= MSG_TYPES_STATUS[msg_id[0]] self.stats[msg_cat] += 1 self.stats['by_module'][self.current_name][msg_cat] += 1 try: |