fabiocaccamo/python-fsutil

View on GitHub
fsutil/__init__.py

Summary

Maintainability
D
2 days
Test Coverage

File __init__.py has 1284 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

from __future__ import annotations

import glob
import hashlib
import json
Severity: Major
Found in fsutil/__init__.py - About 3 days to fix

    Function create_tar_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_tar_file(
        path: PathIn,
        content_paths: list[PathIn],
        *,
        overwrite: bool = True,
    Severity: Minor
    Found in fsutil/__init__.py - About 1 hr to fix

    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_zip_file has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    def create_zip_file(
        path: PathIn,
        content_paths: list[PathIn],
        *,
        overwrite: bool = True,
    Severity: Minor
    Found in fsutil/__init__.py - About 1 hr to fix

    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 download_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def download_file(
        url: str,
        *,
        dirpath: PathIn | None = None,
        filename: str | None = None,
    Severity: Minor
    Found in fsutil/__init__.py - About 1 hr to fix

    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 _read_file_lines_in_range has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _read_file_lines_in_range(
        path: PathIn,
        *,
        line_start: int = 0,
        line_end: int = -1,
    Severity: Minor
    Found in fsutil/__init__.py - About 55 mins to fix

    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_unique_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_unique_name(
        path: PathIn,
        *,
        prefix: str = "",
        suffix: str = "",
    Severity: Minor
    Found in fsutil/__init__.py - About 55 mins to fix

    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 transform_filepath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def transform_filepath(
        path: PathIn,
        *,
        dirpath: str | Callable[[str], str] | None = None,
        basename: str | Callable[[str], str] | None = None,
    Severity: Minor
    Found in fsutil/__init__.py - About 55 mins to fix

    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 read_file_lines has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def read_file_lines(
    Severity: Major
    Found in fsutil/__init__.py - About 50 mins to fix

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

      def extract_tar_file(
      Severity: Minor
      Found in fsutil/__init__.py - About 45 mins to fix

        Function download_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Wontfix

        def download_file(
        Severity: Minor
        Found in fsutil/__init__.py - About 45 mins to fix

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

          def get_unique_name(
          Severity: Minor
          Found in fsutil/__init__.py - About 45 mins to fix

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

            def write_file(
            Severity: Minor
            Found in fsutil/__init__.py - About 45 mins to fix

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

              def copy_dir(
              Severity: Minor
              Found in fsutil/__init__.py - About 35 mins to fix

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

                def transform_filepath(
                Severity: Minor
                Found in fsutil/__init__.py - About 35 mins to fix

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

                  def move_dir(
                  Severity: Minor
                  Found in fsutil/__init__.py - About 35 mins to fix

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

                    def _write_file_atomic(
                    Severity: Minor
                    Found in fsutil/__init__.py - About 35 mins to fix

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

                      def create_tar_file(
                      Severity: Minor
                      Found in fsutil/__init__.py - About 35 mins to fix

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

                        def write_file_json(
                        Severity: Minor
                        Found in fsutil/__init__.py - About 35 mins to fix

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

                          def extract_zip_file(
                          Severity: Minor
                          Found in fsutil/__init__.py - About 35 mins to fix

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

                            def _write_file_non_atomic(
                            Severity: Minor
                            Found in fsutil/__init__.py - About 35 mins to fix

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

                              def copy_file(
                              Severity: Minor
                              Found in fsutil/__init__.py - About 35 mins to fix

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

                                def move_file(
                                Severity: Minor
                                Found in fsutil/__init__.py - About 35 mins to fix

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

                                  def create_zip_file(
                                  Severity: Minor
                                  Found in fsutil/__init__.py - About 35 mins to fix

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

                                    def _read_file_lines_in_range(
                                    Severity: Minor
                                    Found in fsutil/__init__.py - About 35 mins to fix

                                      Function _write_file_atomic has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      def _write_file_atomic(
                                          path: PathIn,
                                          content: str,
                                          *,
                                          append: bool = False,
                                      Severity: Minor
                                      Found in fsutil/__init__.py - About 35 mins to fix

                                      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 _clean_dir_empty_dirs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Wontfix

                                      def _clean_dir_empty_dirs(path: PathIn) -> None:
                                          path = _get_path(path)
                                          for basepath, dirnames, _ in os.walk(path, topdown=False):
                                              for dirname in dirnames:
                                                  dirpath = os.path.join(basepath, dirname)
                                      Severity: Minor
                                      Found in fsutil/__init__.py - About 25 mins to fix

                                      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_dir_size has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Wontfix

                                      def get_dir_size(path: PathIn) -> int:
                                          """
                                          Get the directory size in bytes.
                                          """
                                          path = _get_path(path)
                                      Severity: Minor
                                      Found in fsutil/__init__.py - About 25 mins to fix

                                      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 _clean_dir_empty_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Wontfix

                                      def _clean_dir_empty_files(path: PathIn) -> None:
                                          path = _get_path(path)
                                          for basepath, _, filenames in os.walk(path, topdown=False):
                                              for filename in filenames:
                                                  filepath = os.path.join(basepath, filename)
                                      Severity: Minor
                                      Found in fsutil/__init__.py - About 25 mins to fix

                                      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

                                      There are no issues that match your filters.

                                      Category
                                      Status