Method: pylint.checkers.base.comparison_checker.ComparisonChecker._check_logical_tautology
Calls: 1141, Exceptions: 0, Paths: 7Back
Path 1: 502 calls (0.44)
Compare (502)
1def _check_logical_tautology(self, node: nodes.Compare) -> None:
2 """Check if identifier is compared against itself.
3
4 :param node: Compare node
5 :Example:
6 val = 786
7 if val == val: # [comparison-with-itself]
8 pass
9 """
10 left_operand = node.left
11 right_operand = node.ops[0][1]
12 operator = node.ops[0][0]
13 if isinstance(left_operand, nodes.Const) and isinstance(
14 right_operand, nodes.Const
15 ):
16 left_operand = left_operand.value
17 right_operand = right_operand.value
18 elif isinstance(left_operand, nodes.Name) and isinstance(
19 right_operand, nodes.Name
20 ):
21 left_operand = left_operand.name
22 right_operand = right_operand.name
23
24 if left_operand == right_operand:
25 suggestion = f"{left_operand} {operator} {right_operand}"
26 self.add_message("comparison-with-itself", node=node, args=(suggestion,))
Path 2: 279 calls (0.24)
Compare (279)
1def _check_logical_tautology(self, node: nodes.Compare) -> None:
2 """Check if identifier is compared against itself.
3
4 :param node: Compare node
5 :Example:
6 val = 786
7 if val == val: # [comparison-with-itself]
8 pass
9 """
10 left_operand = node.left
11 right_operand = node.ops[0][1]
12 operator = node.ops[0][0]
13 if isinstance(left_operand, nodes.Const) and isinstance(
14 right_operand, nodes.Const
15 ):
16 left_operand = left_operand.value
17 right_operand = right_operand.value
18 elif isinstance(left_operand, nodes.Name) and isinstance(
19 right_operand, nodes.Name
20 ):
21 left_operand = left_operand.name
22 right_operand = right_operand.name
23
24 if left_operand == right_operand:
25 suggestion = f"{left_operand} {operator} {right_operand}"
26 self.add_message("comparison-with-itself", node=node, args=(suggestion,))
Path 3: 164 calls (0.14)
Compare (164)
1def _check_logical_tautology(self, node: nodes.Compare) -> None:
2 """Check if identifier is compared against itself.
3
4 :param node: Compare node
5 :Example:
6 val = 786
7 if val == val: # [comparison-with-itself]
8 pass
9 """
10 left_operand = node.left
11 right_operand = node.ops[0][1]
12 operator = node.ops[0][0]
13 if isinstance(left_operand, nodes.Const) and isinstance(
14 right_operand, nodes.Const
15 ):
16 left_operand = left_operand.value
17 right_operand = right_operand.value
18 elif isinstance(left_operand, nodes.Name) and isinstance(
19 right_operand, nodes.Name
20 ):
21 left_operand = left_operand.name
22 right_operand = right_operand.name
23
24 if left_operand == right_operand:
25 suggestion = f"{left_operand} {operator} {right_operand}"
26 self.add_message("comparison-with-itself", node=node, args=(suggestion,))
Path 4: 129 calls (0.11)
Compare (129)
1def _check_logical_tautology(self, node: nodes.Compare) -> None:
2 """Check if identifier is compared against itself.
3
4 :param node: Compare node
5 :Example:
6 val = 786
7 if val == val: # [comparison-with-itself]
8 pass
9 """
10 left_operand = node.left
11 right_operand = node.ops[0][1]
12 operator = node.ops[0][0]
13 if isinstance(left_operand, nodes.Const) and isinstance(
14 right_operand, nodes.Const
15 ):
16 left_operand = left_operand.value
17 right_operand = right_operand.value
18 elif isinstance(left_operand, nodes.Name) and isinstance(
19 right_operand, nodes.Name
20 ):
21 left_operand = left_operand.name
22 right_operand = right_operand.name
23
24 if left_operand == right_operand:
25 suggestion = f"{left_operand} {operator} {right_operand}"
26 self.add_message("comparison-with-itself", node=node, args=(suggestion,))
Path 5: 37 calls (0.03)
Compare (37)
1def _check_logical_tautology(self, node: nodes.Compare) -> None:
2 """Check if identifier is compared against itself.
3
4 :param node: Compare node
5 :Example:
6 val = 786
7 if val == val: # [comparison-with-itself]
8 pass
9 """
10 left_operand = node.left
11 right_operand = node.ops[0][1]
12 operator = node.ops[0][0]
13 if isinstance(left_operand, nodes.Const) and isinstance(
14 right_operand, nodes.Const
15 ):
16 left_operand = left_operand.value
17 right_operand = right_operand.value
18 elif isinstance(left_operand, nodes.Name) and isinstance(
19 right_operand, nodes.Name
20 ):
21 left_operand = left_operand.name
22 right_operand = right_operand.name
23
24 if left_operand == right_operand:
25 suggestion = f"{left_operand} {operator} {right_operand}"
26 self.add_message("comparison-with-itself", node=node, args=(suggestion,))
Path 6: 23 calls (0.02)
Compare (23)
1def _check_logical_tautology(self, node: nodes.Compare) -> None:
2 """Check if identifier is compared against itself.
3
4 :param node: Compare node
5 :Example:
6 val = 786
7 if val == val: # [comparison-with-itself]
8 pass
9 """
10 left_operand = node.left
11 right_operand = node.ops[0][1]
12 operator = node.ops[0][0]
13 if isinstance(left_operand, nodes.Const) and isinstance(
14 right_operand, nodes.Const
15 ):
16 left_operand = left_operand.value
17 right_operand = right_operand.value
18 elif isinstance(left_operand, nodes.Name) and isinstance(
19 right_operand, nodes.Name
20 ):
21 left_operand = left_operand.name
22 right_operand = right_operand.name
23
24 if left_operand == right_operand:
25 suggestion = f"{left_operand} {operator} {right_operand}"
26 self.add_message("comparison-with-itself", node=node, args=(suggestion,))
Path 7: 7 calls (0.01)
Compare (7)
1def _check_logical_tautology(self, node: nodes.Compare) -> None:
2 """Check if identifier is compared against itself.
3
4 :param node: Compare node
5 :Example:
6 val = 786
7 if val == val: # [comparison-with-itself]
8 pass
9 """
10 left_operand = node.left
11 right_operand = node.ops[0][1]
12 operator = node.ops[0][0]
13 if isinstance(left_operand, nodes.Const) and isinstance(
14 right_operand, nodes.Const
15 ):
16 left_operand = left_operand.value
17 right_operand = right_operand.value
18 elif isinstance(left_operand, nodes.Name) and isinstance(
19 right_operand, nodes.Name
20 ):
21 left_operand = left_operand.name
22 right_operand = right_operand.name
23
24 if left_operand == right_operand:
25 suggestion = f"{left_operand} {operator} {right_operand}"
26 self.add_message("comparison-with-itself", node=node, args=(suggestion,))