Showing 16 of 16 total issues
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 main
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def main(
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
Function __str__
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def __str__(self) -> str:
"""Render a color report of the current state.
Use `click.unstyle` to remove colors.
"""
- 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_project_root
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_project_root(srcs: Iterable[str]) -> Path:
"""
Return a directory containing .git, .hg, or .reformat-gherkin.yaml.
That directory can be one of the directories passed in `srcs` or their
- 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 reformat_stream_or_path
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def reformat_stream_or_path(
Function read_config_file
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def read_config_file(
ctx: click.Context,
_: click.Parameter,
value: Optional[str],
) -> Optional[str]:
- 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_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
Avoid too many return
statements within this function. Open
return directory # pragma: no cover
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 reformat
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def reformat(src: Tuple[str], report: Report, *, options: Options):
use_stdin = "-" in src
sources = find_sources(filter((lambda it: it != "-"), src))
if not sources and not use_stdin:
- 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"