Showing 59 of 61 total issues
Function _refactor
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def _refactor(self, original_lines: List[str]) -> str:
"""Remove all unused imports from given `original_lines`.
:param original_lines: unmodified lines.
:reutrns: fixed source code.
- 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 remove_useless_passes
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def remove_useless_passes(source_lines: List[str]) -> List[str]:
"""Remove any useless `pass`.
:param source_lines: source code lines.
:returns: clean source code 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 get_local_import_from_path
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def get_local_import_from_path(
path: Path, module: str, package: str, level: int
) -> Optional[Path]:
"""Find the given local module file.py/__init_.py path.
- 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
SourceAnalyzer
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class SourceAnalyzer(ast.NodeVisitor):
"""AST source code analyzer.
>>> import ast
Function get_module_path
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def get_module_path(
paths: Set[Path], module: str, package: str = "", level: int = 0
) -> Optional[Path]:
"""Get the `module` path from the given `paths`.
- 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 yield_sources
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def yield_sources(
path: Path,
include: Pattern[str],
exclude: Pattern[str],
extend_exclude: Pattern[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 changed_file
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def changed_file(self, path: Path) -> None:
"""Increment `self._changed_files`. Write a message to stdout.
:param path: the changed file path.
"""
- 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 generic_visit
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def generic_visit(self, node):
"""Called if no explicit visitor function exists for a node
(override)."""
# Continue visiting if only if `__all__` has not overridden.
if (not self._has_all) or isinstance(node, ast.AugAssign):
- 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 _config_loader
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def _config_loader(self, config_dict: dict) -> None:
# k, v: config loader.
if config_dict:
for k, v in config_dict.items():
# Python preserved name.
- 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 visit_Subscript
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def visit_Subscript(self, node: ast.Subscript) -> None:
#: Support semi string type assigment
#:
#: >>> from ast import Import, ImportFrom
#: >>> from typing import Union, List
- 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 17 arguments (exceeds 4 allowed). Consider refactoring. Open
def main( # pylint: disable=R0913,R0914
Function generic_visit
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def generic_visit(self, node):
"""Called if no explicit visitor function exists for a node
(override)."""
# Continue visiting if only if there's no know side effects.
if self._has_side_effects is HasSideEffects.NO:
- 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 get_third_party_lib_paths
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_third_party_lib_paths() -> Tuple[Set[Path], Set[Path]]:
"""Get paths to third party library modules.
:returns: a tuple of a set of paths of third party library modules
and a set of paths from `.pth` file(s) content, respectively.
- 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 _output
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def _output(
self,
fixed_lines: List[str],
original_lines: List[str],
encoding: 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 _should_remove
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def _should_remove(
self, node: Union[Import, ImportFrom], alias: ast.alias, is_star: bool
) -> bool:
"""Check if the alias should be removed or not.
- 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 visit_Call
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def visit_Call(self, node: ast.Call):
func = node.func
#: Support casting case.
#: >>> from typing import cast
- 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 expand_import_star
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def expand_import_star(
node: Union[ast.ImportFrom, _nodes.ImportFrom], path: Path
) -> Union[ast.ImportFrom, _nodes.ImportFrom]:
"""Expand import star statement, replace the `*` with a list of ast.alias.
- 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 _check_path
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _check_path(self) -> None:
# Validate `self.paths`.
if self.paths:
for path in self.paths.copy():
if not (path.is_dir() or path.is_file()):
- 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 visit_Expr
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def visit_Expr(self, node: ast.Expr):
#: Support `__all__` dunder overriding with
#: `append` and `extend` operations:
#:
#: >>> import x, y, z
- 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 safe_read
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def safe_read(
path: Path, permissions: tuple = (os.R_OK, os.W_OK)
) -> Tuple[FileContent, Encoding, NewLine]:
"""Read file content with encoding and new line type detection.
- 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"