Function review_hunks
has a Cognitive Complexity of 90 (exceeds 10 allowed). Consider refactoring. Open
def review_hunks(self) -> None:
"""Review hunks."""
def find_pending(start: int, end: int) -> int | None:
step = -1 if start > end else +1
for pending in range(start, end, step):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function format_diff
has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring. Open
def format_diff(self) -> Iterable[str]:
"""Color diff lines."""
diff = iter(self.diff)
fmt: str | None = ''
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function create_diff
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
def create_diff(self) -> Iterable[str]:
"""Generator of diff text for this hunk, without formatting.
Check each line ends with line feed to prevent behaviour like
:issue:`46395`
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function color_line
has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring. Open
def color_line(self, line: str, line_ref: str | None = None) -> str:
"""Color line characters.
If line_ref is None, the whole line is colored.
If line_ref[i] is not blank, line[i] is colored.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if hunk.reviewed == Hunk.PENDING:
hunk.reviewed = Hunk.NOT_APPR
elif choice in ['a', 'd']:
Avoid deeply nested control flow statements. Open
if hunk.reviewed == Hunk.PENDING:
hunk.reviewed = \
Hunk.APPR if choice == 'a' else Hunk.NOT_APPR
position = find_pending(0, position)
Function _generate_super_hunks
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
def _generate_super_hunks(self, hunks: Iterable[Hunk] | None = None
) -> list[_SuperHunk]:
if hunks is None:
hunks = self.hunks
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
TODO found Open
# TODO
- Exclude checks