fix elif-used rule

The bug was introduced when porting the rule from pylint core to an extension

authorLaura Médioni <laura.medioni@logilab.fr>
changeset006fd348be8f
branchdefault
phasepublic
hiddenno
parent revision#d59766d8c147 Add changelog entry for 0c2ba76
child revision#67a5812decfc Add else-if-used rule functional test
files modified by this revision
pylint/extensions/check_elif.py
# HG changeset patch
# User Laura Médioni <laura.medioni@logilab.fr>
# Date 1448872139 -3600
# Mon Nov 30 09:28:59 2015 +0100
# Node ID 006fd348be8fb7c7e4ae81beba60cfbd583b426c
# Parent d59766d8c1473f37ce501256cc4c8ae982116a01
fix elif-used rule

The bug was introduced when porting the rule from pylint core to an extension

diff --git a/pylint/extensions/check_elif.py b/pylint/extensions/check_elif.py
@@ -23,31 +23,17 @@
1 
2      def _init(self):
3          self._elifs = []
4          self._if_counter = 0
5 
6 -    def _is_actual_elif(self, node):
7 -        """Check if the given node is an actual elif
8 -
9 -        This is a problem we're having with the builtin ast module,
10 -        which splits `elif` branches into a separate if statement.
11 -        Unfortunately we need to know the exact type in certain
12 -        cases.
13 -        """
14 -
15 -        if isinstance(node.parent, astroid.If):
16 -            orelse = node.parent.orelse
17 -            # current if node must directly follow a "else"
18 -            if orelse and orelse == [node]:
19 -                if self._elifs[self._if_counter]:
20 -                    return True
21 -        return False
22 -
23      def process_tokens(self, tokens):
24          # Process tokens and look for 'if' or 'elif'
25          for _, token, _, _, _ in tokens:
26 -            self._elifs.append(True if token == 'elif' else False)
27 +            if token == 'elif':
28 +                self._elifs.append(True)
29 +            elif token == 'if':
30 +                self._elifs.append(False)
31 
32      def leave_module(self, _):
33          self._init()
34 
35      def visit_ifexp(self, _):