| Index: third_party/pylint/checkers/design_analysis.py
 | 
| diff --git a/third_party/pylint/checkers/design_analysis.py b/third_party/pylint/checkers/design_analysis.py
 | 
| index 0725ccf0c091999511518840f1c4badf6efc19a3..0a7a307cfb2987be43148b8ad658cfef790003a9 100644
 | 
| --- a/third_party/pylint/checkers/design_analysis.py
 | 
| +++ b/third_party/pylint/checkers/design_analysis.py
 | 
| @@ -15,14 +15,15 @@
 | 
|  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 | 
|  """check for signs of poor design"""
 | 
|  
 | 
| +import re
 | 
| +from collections import defaultdict
 | 
| +
 | 
|  from astroid import Function, If, InferenceError
 | 
|  
 | 
|  from pylint.interfaces import IAstroidChecker
 | 
|  from pylint.checkers import BaseChecker
 | 
|  from pylint.checkers.utils import check_messages
 | 
|  
 | 
| -import re
 | 
| -
 | 
|  # regexp for ignored argument name
 | 
|  IGNORED_ARGUMENT_NAMES = re.compile('_.*')
 | 
|  
 | 
| @@ -174,7 +175,7 @@ class MisdesignChecker(BaseChecker):
 | 
|          """initialize visit variables"""
 | 
|          self.stats = self.linter.add_stats()
 | 
|          self._returns = []
 | 
| -        self._branches = []
 | 
| +        self._branches = defaultdict(int)
 | 
|          self._used_abstracts = {}
 | 
|          self._used_ifaces = {}
 | 
|          self._abstracts = []
 | 
| @@ -200,7 +201,6 @@ class MisdesignChecker(BaseChecker):
 | 
|      def visit_class(self, node):
 | 
|          """check size of inheritance hierarchy and number of instance attributes
 | 
|          """
 | 
| -        self._inc_branch()
 | 
|          # Is the total inheritance hierarchy is 7 or less?
 | 
|          nb_parents = len(list(node.ancestors()))
 | 
|          if nb_parents > self.config.max_parents:
 | 
| @@ -241,12 +241,9 @@ class MisdesignChecker(BaseChecker):
 | 
|      def leave_class(self, node):
 | 
|          """check number of public methods"""
 | 
|          nb_public_methods = 0
 | 
| -        special_methods = set()
 | 
| -        for method in node.methods():
 | 
| +        for method in node.mymethods():
 | 
|              if not method.name.startswith('_'):
 | 
|                  nb_public_methods += 1
 | 
| -            if method.name.startswith("__"):
 | 
| -                special_methods.add(method.name)
 | 
|          # Does the class contain less than 20 public methods ?
 | 
|          if nb_public_methods > self.config.max_public_methods:
 | 
|              self.add_message('too-many-public-methods', node=node,
 | 
| @@ -257,20 +254,19 @@ class MisdesignChecker(BaseChecker):
 | 
|              return
 | 
|          # Does the class contain more than 5 public methods ?
 | 
|          if nb_public_methods < self.config.min_public_methods:
 | 
| -            self.add_message('R0903', node=node,
 | 
| +            self.add_message('too-few-public-methods', node=node,
 | 
|                               args=(nb_public_methods,
 | 
|                                     self.config.min_public_methods))
 | 
|  
 | 
|      @check_messages('too-many-return-statements', 'too-many-branches',
 | 
| -                    'too-many-arguments', 'too-many-locals', 'too-many-statements')
 | 
| +                    'too-many-arguments', 'too-many-locals',
 | 
| +                    'too-many-statements')
 | 
|      def visit_function(self, node):
 | 
|          """check function name, docstring, arguments, redefinition,
 | 
|          variable names, max locals
 | 
|          """
 | 
| -        self._inc_branch()
 | 
|          # init branch and returns counters
 | 
|          self._returns.append(0)
 | 
| -        self._branches.append(0)
 | 
|          # check number of arguments
 | 
|          args = node.args.args
 | 
|          if args is not None:
 | 
| @@ -291,7 +287,9 @@ class MisdesignChecker(BaseChecker):
 | 
|          # init statements counter
 | 
|          self._stmts = 1
 | 
|  
 | 
| -    @check_messages('too-many-return-statements', 'too-many-branches', 'too-many-arguments', 'too-many-locals', 'too-many-statements')
 | 
| +    @check_messages('too-many-return-statements', 'too-many-branches',
 | 
| +                    'too-many-arguments', 'too-many-locals',
 | 
| +                    'too-many-statements')
 | 
|      def leave_function(self, node):
 | 
|          """most of the work is done here on close:
 | 
|          checks for max returns, branch, return in __init__
 | 
| @@ -300,7 +298,7 @@ class MisdesignChecker(BaseChecker):
 | 
|          if returns > self.config.max_returns:
 | 
|              self.add_message('too-many-return-statements', node=node,
 | 
|                               args=(returns, self.config.max_returns))
 | 
| -        branches = self._branches.pop()
 | 
| +        branches = self._branches[node]
 | 
|          if branches > self.config.max_branches:
 | 
|              self.add_message('too-many-branches', node=node,
 | 
|                               args=(branches, self.config.max_branches))
 | 
| @@ -327,12 +325,12 @@ class MisdesignChecker(BaseChecker):
 | 
|          branches = len(node.handlers)
 | 
|          if node.orelse:
 | 
|              branches += 1
 | 
| -        self._inc_branch(branches)
 | 
| +        self._inc_branch(node, branches)
 | 
|          self._stmts += branches
 | 
|  
 | 
| -    def visit_tryfinally(self, _):
 | 
| +    def visit_tryfinally(self, node):
 | 
|          """increments the branches counter"""
 | 
| -        self._inc_branch(2)
 | 
| +        self._inc_branch(node, 2)
 | 
|          self._stmts += 2
 | 
|  
 | 
|      def visit_if(self, node):
 | 
| @@ -342,7 +340,7 @@ class MisdesignChecker(BaseChecker):
 | 
|          if node.orelse and (len(node.orelse) > 1 or
 | 
|                              not isinstance(node.orelse[0], If)):
 | 
|              branches += 1
 | 
| -        self._inc_branch(branches)
 | 
| +        self._inc_branch(node, branches)
 | 
|          self._stmts += branches
 | 
|  
 | 
|      def visit_while(self, node):
 | 
| @@ -350,15 +348,13 @@ class MisdesignChecker(BaseChecker):
 | 
|          branches = 1
 | 
|          if node.orelse:
 | 
|              branches += 1
 | 
| -        self._inc_branch(branches)
 | 
| +        self._inc_branch(node, branches)
 | 
|  
 | 
|      visit_for = visit_while
 | 
|  
 | 
| -    def _inc_branch(self, branchesnum=1):
 | 
| +    def _inc_branch(self, node, branchesnum=1):
 | 
|          """increments the branches counter"""
 | 
| -        branches = self._branches
 | 
| -        for i in xrange(len(branches)):
 | 
| -            branches[i] += branchesnum
 | 
| +        self._branches[node.scope()] += branchesnum
 | 
|  
 | 
|      # FIXME: make a nice report...
 | 
|  
 | 
| 
 |