hadialqattan/pycln

View on GitHub

Showing 59 of 61 total issues

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
Severity: Minor
Found in pycln/utils/scan.py - About 1 hr to fix

Function visit_ClassDef has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def visit_ClassDef(self, node: ast.ClassDef):
#: Support imports used in generics and wrapped in string:
#:
#: >>> from typing import Generic
#: >>> from foo import Bar
Severity: Minor
Found in pycln/utils/scan.py - About 1 hr to fix

Function _get_end_lineno has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def _get_end_lineno(self, lineno: int, is_parentheses: bool) -> int:
# Get `ast.ImportFrom` `end_lineno` of the given `lineno`.
lines_len = len(self._lines)
for end_lineno in range(lineno, lines_len):
if is_parentheses:
Severity: Minor
Found in pycln/utils/scan.py - About 1 hr to fix

Function _is_partially_used has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def _is_partially_used(self, alias: ast.alias, is_star: bool) -> bool:
"""Determine if the alias name partially used or not.
 
:param alias: an `ast.alias` node.
:param is_star: is it a '*' import.
Severity: Minor
Found in pycln/utils/refactor.py - About 1 hr to fix

Function _add_list_names has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _add_list_names(self, node: List[ast.expr]) -> None:
# Safely add list `const/str` names to `self._source_stats.name_`.
for item in node:
if isinstance(item, (ast.Constant, ast.Str)):
key = "s" if hasattr(item, "s") else "value"
Severity: Minor
Found in pycln/utils/scan.py - About 55 mins to fix

Function main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def main( # pylint: disable=R0913,R0914
paths: List[Path] = typer.Argument(None, help="Directories or files paths."),
config: Optional[Path] = typer.Option(
None,
"--config",
Severity: Minor
Found in pycln/cli.py - About 55 mins to fix

Function get_import_from_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def get_import_from_path(
path: Path, module: str, package: str, level: int
) -> Optional[Path]:
"""Find the given module file.py/__init_.py path.
 
 
Severity: Minor
Found in pycln/utils/pathu.py - About 55 mins to fix

Function _add_list_names has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _add_list_names(self, node: List[ast.expr]) -> None:
# Safely add list `const/str` names to `self._importables`.
for item in node:
if isinstance(item, (ast.Constant, ast.Str)):
key = "s" if hasattr(item, "s") else "value"
Severity: Minor
Found in pycln/utils/scan.py - About 55 mins to fix

Function _expand_import_star has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _expand_import_star(
self, node: ImportFrom
) -> Tuple[ImportFrom, Optional[bool]]:
"""Expand import star statement, `scan.expand_import_star` abstraction.
 
 
Severity: Minor
Found in pycln/utils/refactor.py - About 55 mins to fix

Function secho has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def secho(
Severity: Major
Found in pycln/utils/report.py - About 50 mins to fix

    Function rebuild_import has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def rebuild_import(
    import_stmnt: str,
    used_names: Set[str],
    path: Path,
    location: NodeLocation,
    Severity: Minor
    Found in pycln/utils/transform.py - About 45 mins to fix

    Function _compute_not_importables has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _compute_not_importables(self, node: Union[FunctionDefT, ast.ClassDef]):
    # Compute class/function not-importables.
    for node_ in ast.iter_child_nodes(node):
    if isinstance(node_, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
    self._not_importables.add(cast(str, node_.name))
    Severity: Minor
    Found in pycln/utils/scan.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

    if isinstance(item, ast.AST):
    self.visit(item)
    elif isinstance(value, ast.AST):
    Severity: Major
    Found in pycln/utils/scan.py - About 45 mins to fix

      Function exit_code has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def exit_code(self) -> int:
      """Return an exit code.
       
      :returns: an exit code (0, 1, 250).
      """
      Severity: Minor
      Found in pycln/utils/report.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

      if not self.configs.expand_stars:
      continue
      self.reporter.expanded_star(self._path, node)
      Severity: Major
      Found in pycln/utils/refactor.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

        if isinstance(item, ast.AST):
        self.visit(item)
        elif isinstance(value, ast.AST):
        Severity: Major
        Found in pycln/utils/scan.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

          if body_len == 2 and ast.get_docstring(parent):
          break
          if body_len > 1:
          Severity: Major
          Found in pycln/utils/refactor.py - About 45 mins to fix

            Function yield_sources has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def yield_sources(
            Severity: Minor
            Found in pycln/utils/pathu.py - About 45 mins to fix

              Function get_standard_lib_paths has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_standard_lib_paths() -> Set[Path]:
              """Get paths to Python standard library modules.
               
              :returns: set of paths to Python standard library modules.
              """
              Severity: Minor
              Found in pycln/utils/pathu.py - About 45 mins to fix

              Function _has_side_effects has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def _has_side_effects( # pylint: disable=dangerous-default-value
              Severity: Minor
              Found in pycln/utils/refactor.py - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language