don't want to run a checker only because of a Fatal error

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changeset7a1e32ae0c60
branchdefault
phasepublic
hiddenno
parent revision#cdea6d2431b5 Add name type in C0103 message
child revision#19502af3b7c9 Add --ignore-imports option to similarity checking. Closes #106534.
files modified by this revision
lint.py
test/unittest_lint.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1348116875 -7200
# Thu Sep 20 06:54:35 2012 +0200
# Node ID 7a1e32ae0c60d872568382a76f3621ce72a81b31
# Parent cdea6d2431b5b4bd1a407dd1df4620087b87038f
don't want to run a checker only because of a Fatal error

diff --git a/lint.py b/lint.py
@@ -494,12 +494,13 @@
1          if not self.config.reports:
2              self.disable_reporters()
3          # get needed checkers
4          neededcheckers = [self]
5          for checker in self.get_checkers()[1:]:
6 +            # fatal errors should not trigger enable / disabling a checker
7              messages = set(msg for msg in checker.msgs
8 -                           if self.is_message_enabled(msg))
9 +                           if msg[0] != 'F' and self.is_message_enabled(msg))
10              if (messages or
11                  any(self.report_is_enabled(r[0]) for r in checker.reports)):
12                  neededcheckers.append(checker)
13                  checker.active_msgs = messages
14          return neededcheckers
diff --git a/test/unittest_lint.py b/test/unittest_lint.py
@@ -296,21 +296,15 @@
15          self.assertFalse('similarities' in [c.name for c in self.linter.prepare_checkers()])
16 
17      def test_disable_alot(self):
18          """check that we disabled a lot of checkers"""
19          self.linter.set_option('reports', False)
20 -        # FIXME should it be necessary to explicitly desactivate failures ?
21          self.linter.set_option('disable', 'R,C,W')
22          checker_names = [c.name for c in self.linter.prepare_checkers()]
23 -        should_not = ('design', 'metrics', 'similarities')
24 -        rest = [name for name in checker_names if name in should_not]
25 -        self.assertListEqual(rest, [])
26 -        self.linter.set_option('disable', 'R,C,W,F')
27 -        checker_names = [c.name for c in self.linter.prepare_checkers()]
28 -        should_not +=  ('format', 'imports')
29 -        rest = [name for name in checker_names if name in should_not]
30 -        self.assertListEqual(rest, [])
31 +        for cname in  ('design', 'metrics', 'similarities',
32 +                       'imports'): # as a Fatal message that should be ignored
33 +            self.assertFalse(cname in checker_names, cname)
34 
35 
36  class ConfigTC(TestCase):
37 
38      def setUp(self):