Showing 4,191 of 4,191 total issues
Wrong hanging indentation before block (add 4 spaces). Open
'eret',
- Read upRead up
- Exclude checks
TODO 'eret', ^ |
Too many branches (110/12) Open
def stem(self, word: str) -> str:
- Read upRead up
- Exclude checks
Used when a function or method has too many branches, making it hard to follow.
Wrong hanging indentation before block (add 4 spaces). Open
'tt',
- Read upRead up
- Exclude checks
TODO 'tt', ^ |
Refactor this function to reduce its Cognitive Complexity from 121 to the 15 allowed. Open
def _group_linkage_intersection(self) -> TCounter[str]:
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Correct one of the identical sub-expressions on both sides of operator "or". Open
or (
initial_diff
== self._lev.dist_abs(
src_initials_str, tar_initials_str,
)
- Read upRead up
- Exclude checks
Using the same value on either side of a binary operator is almost always a mistake. In the case of logical operators, it is either a copy/paste error and therefore a bug, or it is simply wasted code, and should be simplified. In the case of bitwise operators and most binary mathematical operators, having the same value on both sides of an operator yields predictable results, and should be simplified.
This rule ignores *
, +
, and =
.
Noncompliant Code Example
if a == a: # Noncompliant work() if a != a: # Noncompliant work() if a == b and a == b: # Noncompliant work() if a == b or a == b: # Noncompliant work() j = 5 / 5 # Noncompliant k = 5 - 5 # Noncompliant
Exceptions
The following are ignored:
- The expression
1 << 1
See
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
- CERT, MSC12-CPP. - Detect and remove code that has no effect
- {rule:python:S1656} - Implements a check on
=
.
Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed. Open
def sim(self, src: str, tar: str) -> float:
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 53 to the 15 allowed. Open
def dist_abs(self, src: str, tar: str) -> float:
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Merge this if statement with the enclosing one. Open
if (ying[i], yang[j]) in adjwt:
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if condition1: if condition2: # ...
Compliant Solution
if condition1 and condition2: # ...
Consider using enumerate instead of iterating with range and len Open
for i in range(len(nums)):
- Read upRead up
- Exclude checks
Emitted when code that iterates with range and len is encountered. Such code can be simplified by using the enumerate builtin.
Too many lines in module (2176/1000) Open
# Copyright 2014-2020 by Christopher C. Little.
- Read upRead up
- Exclude checks
Used when a module has too many lines, reducing its readability.
Too many public methods (65/20) Open
class ConfusionTable:
- Read upRead up
- Exclude checks
Used when class has too many public methods, try to reduce this to get a simpler (and so easier to use) class.
Wrong hanging indentation before block (add 4 spaces). Open
'ethed',
- Read upRead up
- Exclude checks
TODO 'ethed', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'eres',
- Read upRead up
- Exclude checks
TODO 'eres', ^ |
Too many branches (18/12) Open
def stem(self, word: str) -> str:
- Read upRead up
- Exclude checks
Used when a function or method has too many branches, making it hard to follow.
Wrong hanging indentation before block (add 4 spaces). Open
'mm',
- Read upRead up
- Exclude checks
TODO 'mm', ^ |
Merge this if statement with the enclosing one. Open
if (src_fn and src_fn in tar_fn) or (tar_fn and tar_fn in src_ln):
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if condition1: if condition2: # ...
Compliant Solution
if condition1 and condition2: # ...
Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed. Open
def tokenize(self, string: str) -> 'CVClusterTokenizer':
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed. Open
def tokenize(self, string: str) -> 'VCClusterTokenizer':
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Wrong hanging indentation before block (add 4 spaces). Open
collection: Union[str, Sequence[str], Set[str]],
- Read upRead up
- Exclude checks
TODO collection: Union[str, Sequence[str], Set[str]], ^ |
Wrong hanging indentation before block (add 4 spaces). Open
metric: Optional[Callable[[str, str], float]] = None,
- Read upRead up
- Exclude checks
TODO metric: Optional[Callable[[str, str], float]] = None, ^ |