File formatter.py
has 373 lines of code (exceeds 250 allowed). Consider refactoring. Open
from itertools import chain, groupby
from typing import (
Any,
Callable,
Dict,
Function __find_nodes_within_rules
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def __find_nodes_within_rules(self) -> Set[Node]:
nodes_within_rules: Set[Node] = set()
feature = self.ast.feature
if feature is not 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 __construct_contexts
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __construct_contexts(self) -> ContextMap:
"""
Construct the information about the context a certain line might need to know to
properly format these lines.
"""
- 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 __find_nodes_with_newline
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def __find_nodes_with_newline(self) -> Set[Node]:
"""
Find all nodes in the AST that needs a new line after it.
"""
- 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 not isinstance(node, Rule):
nodes_within_rules.add(node)
Function generate_step_line
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def generate_step_line(
Function __construct_contexts_for_comments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __construct_contexts_for_comments(nodes: List[Node]) -> ContextMap:
# The context of each comment line is the next non-comment line.
#
# The steps of the algorithm:
# 1. Group the nodes into comments and non-comments
- 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 __group_tags
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __group_tags(self):
"""
Group the tags of a node, so that we can render them on a single line.
"""
- 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 extract_rows
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def extract_rows(node: Union[DataTable, Examples]) -> List[TableRow]:
"""
Extract table rows from either a Datable or Example instance.
"""
- 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"