Path 1: 1002 calls (0.66)

ClassDef (1002)

1@only_required_for_messages("too-few-public-methods", "too-many-public-methods")
2    def leave_classdef(self, node: nodes.ClassDef) -> None:
3        """Check number of public methods."""
4        my_methods = sum(
5            1 for method in node.mymethods() if not method.name.startswith("_")
6        )
7
8        # Does the class contain less than n public methods ?
9        # This checks only the methods defined in the current class,
10        # since the user might not have control over the classes
11        # from the ancestors. It avoids some false positives
12        # for classes such as unittest.TestCase, which provides
13        # a lot of assert methods. It doesn't make sense to warn
14        # when the user subclasses TestCase to add his own tests.
15        if my_methods > self.linter.config.max_public_methods:
16            self.add_message(
17                "too-many-public-methods",
18                node=node,
19                args=(my_methods, self.linter.config.max_public_methods),
20            )
21
22        # Stop here if the class is excluded via configuration.
23        if node.type == "class" and self._exclude_too_few_public_methods:
24            for ancestor in node.ancestors():
25                if any(
26                    pattern.match(ancestor.qname())
27                    for pattern in self._exclude_too_few_public_methods
28                ):
29                    return
30
31        # Stop here for exception, metaclass, interface classes and other
32        # classes for which we don't need to count the methods.
33        if node.type != "class" or _is_exempt_from_public_methods(node):
34            return
35
36        # Does the class contain more than n public methods ?
37        # This checks all the methods defined by ancestors and
38        # by the current class.
39        all_methods = _count_methods_in_class(node)
40        if all_methods < self.linter.config.min_public_methods:
41            self.add_message(
42                "too-few-public-methods",
43                node=node,
44                args=(all_methods, self.linter.config.min_public_methods),
45            )
            

Path 2: 317 calls (0.21)

ClassDef (317)

1@only_required_for_messages("too-few-public-methods", "too-many-public-methods")
2    def leave_classdef(self, node: nodes.ClassDef) -> None:
3        """Check number of public methods."""
4        my_methods = sum(
5            1 for method in node.mymethods() if not method.name.startswith("_")
6        )
7
8        # Does the class contain less than n public methods ?
9        # This checks only the methods defined in the current class,
10        # since the user might not have control over the classes
11        # from the ancestors. It avoids some false positives
12        # for classes such as unittest.TestCase, which provides
13        # a lot of assert methods. It doesn't make sense to warn
14        # when the user subclasses TestCase to add his own tests.
15        if my_methods > self.linter.config.max_public_methods:
16            self.add_message(
17                "too-many-public-methods",
18                node=node,
19                args=(my_methods, self.linter.config.max_public_methods),
20            )
21
22        # Stop here if the class is excluded via configuration.
23        if node.type == "class" and self._exclude_too_few_public_methods:
24            for ancestor in node.ancestors():
25                if any(
26                    pattern.match(ancestor.qname())
27                    for pattern in self._exclude_too_few_public_methods
28                ):
29                    return
30
31        # Stop here for exception, metaclass, interface classes and other
32        # classes for which we don't need to count the methods.
33        if node.type != "class" or _is_exempt_from_public_methods(node):
34            return
35
36        # Does the class contain more than n public methods ?
37        # This checks all the methods defined by ancestors and
38        # by the current class.
39        all_methods = _count_methods_in_class(node)
40        if all_methods < self.linter.config.min_public_methods:
41            self.add_message(
42                "too-few-public-methods",
43                node=node,
44                args=(all_methods, self.linter.config.min_public_methods),
45            )
            

Path 3: 194 calls (0.13)

ClassDef (194)

None (194)

1@only_required_for_messages("too-few-public-methods", "too-many-public-methods")
2    def leave_classdef(self, node: nodes.ClassDef) -> None:
3        """Check number of public methods."""
4        my_methods = sum(
5            1 for method in node.mymethods() if not method.name.startswith("_")
6        )
7
8        # Does the class contain less than n public methods ?
9        # This checks only the methods defined in the current class,
10        # since the user might not have control over the classes
11        # from the ancestors. It avoids some false positives
12        # for classes such as unittest.TestCase, which provides
13        # a lot of assert methods. It doesn't make sense to warn
14        # when the user subclasses TestCase to add his own tests.
15        if my_methods > self.linter.config.max_public_methods:
16            self.add_message(
17                "too-many-public-methods",
18                node=node,
19                args=(my_methods, self.linter.config.max_public_methods),
20            )
21
22        # Stop here if the class is excluded via configuration.
23        if node.type == "class" and self._exclude_too_few_public_methods:
24            for ancestor in node.ancestors():
25                if any(
26                    pattern.match(ancestor.qname())
27                    for pattern in self._exclude_too_few_public_methods
28                ):
29                    return
30
31        # Stop here for exception, metaclass, interface classes and other
32        # classes for which we don't need to count the methods.
33        if node.type != "class" or _is_exempt_from_public_methods(node):
34            return
35
36        # Does the class contain more than n public methods ?
37        # This checks all the methods defined by ancestors and
38        # by the current class.
39        all_methods = _count_methods_in_class(node)
40        if all_methods < self.linter.config.min_public_methods:
41            self.add_message(
42                "too-few-public-methods",
43                node=node,
44                args=(all_methods, self.linter.config.min_public_methods),
45            )
            

Path 4: 3 calls (0.0)

ClassDef (3)

1@only_required_for_messages("too-few-public-methods", "too-many-public-methods")
2    def leave_classdef(self, node: nodes.ClassDef) -> None:
3        """Check number of public methods."""
4        my_methods = sum(
5            1 for method in node.mymethods() if not method.name.startswith("_")
6        )
7
8        # Does the class contain less than n public methods ?
9        # This checks only the methods defined in the current class,
10        # since the user might not have control over the classes
11        # from the ancestors. It avoids some false positives
12        # for classes such as unittest.TestCase, which provides
13        # a lot of assert methods. It doesn't make sense to warn
14        # when the user subclasses TestCase to add his own tests.
15        if my_methods > self.linter.config.max_public_methods:
16            self.add_message(
17                "too-many-public-methods",
18                node=node,
19                args=(my_methods, self.linter.config.max_public_methods),
20            )
21
22        # Stop here if the class is excluded via configuration.
23        if node.type == "class" and self._exclude_too_few_public_methods:
24            for ancestor in node.ancestors():
25                if any(
26                    pattern.match(ancestor.qname())
27                    for pattern in self._exclude_too_few_public_methods
28                ):
29                    return
30
31        # Stop here for exception, metaclass, interface classes and other
32        # classes for which we don't need to count the methods.
33        if node.type != "class" or _is_exempt_from_public_methods(node):
34            return
35
36        # Does the class contain more than n public methods ?
37        # This checks all the methods defined by ancestors and
38        # by the current class.
39        all_methods = _count_methods_in_class(node)
40        if all_methods < self.linter.config.min_public_methods:
41            self.add_message(
42                "too-few-public-methods",
43                node=node,
44                args=(all_methods, self.linter.config.min_public_methods),
45            )
            

Path 5: 2 calls (0.0)

ClassDef (2)

None (2)

GeneratorExit (2)

1@only_required_for_messages("too-few-public-methods", "too-many-public-methods")
2    def leave_classdef(self, node: nodes.ClassDef) -> None:
3        """Check number of public methods."""
4        my_methods = sum(
5            1 for method in node.mymethods() if not method.name.startswith("_")
6        )
7
8        # Does the class contain less than n public methods ?
9        # This checks only the methods defined in the current class,
10        # since the user might not have control over the classes
11        # from the ancestors. It avoids some false positives
12        # for classes such as unittest.TestCase, which provides
13        # a lot of assert methods. It doesn't make sense to warn
14        # when the user subclasses TestCase to add his own tests.
15        if my_methods > self.linter.config.max_public_methods:
16            self.add_message(
17                "too-many-public-methods",
18                node=node,
19                args=(my_methods, self.linter.config.max_public_methods),
20            )
21
22        # Stop here if the class is excluded via configuration.
23        if node.type == "class" and self._exclude_too_few_public_methods:
24            for ancestor in node.ancestors():
25                if any(
26                    pattern.match(ancestor.qname())
27                    for pattern in self._exclude_too_few_public_methods
28                ):
29                    return
30
31        # Stop here for exception, metaclass, interface classes and other
32        # classes for which we don't need to count the methods.
33        if node.type != "class" or _is_exempt_from_public_methods(node):
34            return
35
36        # Does the class contain more than n public methods ?
37        # This checks all the methods defined by ancestors and
38        # by the current class.
39        all_methods = _count_methods_in_class(node)
40        if all_methods < self.linter.config.min_public_methods:
41            self.add_message(
42                "too-few-public-methods",
43                node=node,
44                args=(all_methods, self.linter.config.min_public_methods),
45            )
            

Path 6: 1 calls (0.0)

ClassDef (1)

1@only_required_for_messages("too-few-public-methods", "too-many-public-methods")
2    def leave_classdef(self, node: nodes.ClassDef) -> None:
3        """Check number of public methods."""
4        my_methods = sum(
5            1 for method in node.mymethods() if not method.name.startswith("_")
6        )
7
8        # Does the class contain less than n public methods ?
9        # This checks only the methods defined in the current class,
10        # since the user might not have control over the classes
11        # from the ancestors. It avoids some false positives
12        # for classes such as unittest.TestCase, which provides
13        # a lot of assert methods. It doesn't make sense to warn
14        # when the user subclasses TestCase to add his own tests.
15        if my_methods > self.linter.config.max_public_methods:
16            self.add_message(
17                "too-many-public-methods",
18                node=node,
19                args=(my_methods, self.linter.config.max_public_methods),
20            )
21
22        # Stop here if the class is excluded via configuration.
23        if node.type == "class" and self._exclude_too_few_public_methods:
24            for ancestor in node.ancestors():
25                if any(
26                    pattern.match(ancestor.qname())
27                    for pattern in self._exclude_too_few_public_methods
28                ):
29                    return
30
31        # Stop here for exception, metaclass, interface classes and other
32        # classes for which we don't need to count the methods.
33        if node.type != "class" or _is_exempt_from_public_methods(node):
34            return
35
36        # Does the class contain more than n public methods ?
37        # This checks all the methods defined by ancestors and
38        # by the current class.
39        all_methods = _count_methods_in_class(node)
40        if all_methods < self.linter.config.min_public_methods:
41            self.add_message(
42                "too-few-public-methods",
43                node=node,
44                args=(all_methods, self.linter.config.min_public_methods),
45            )