durandtibo/gravitorch

View on GitHub

Showing 95 of 134 total issues

Function to_flat_dict has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def to_flat_dict(
    data: Any,
    prefix: str | None = None,
    separator: str = ".",
    to_str: type[object] | tuple[type[object], ...] | None = None,
Severity: Minor
Found in src/gravitorch/utils/mapping.py - About 2 hrs 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 find_module_state_dict has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def find_module_state_dict(state_dict: dict | list | tuple, module_keys: set) -> dict:
    r"""Tries to find automatically the part of the state dict related to
    a module.

    The user should specify the set of module's keys:
Severity: Minor
Found in src/gravitorch/nn/utils/state_dict.py - About 2 hrs 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_module_output_size has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def get_module_output_size(module: nn.Module) -> int:
    r"""Gets the output size of a module.

    This function works only for the module with a single output size.

Severity: Minor
Found in src/gravitorch/nn/utils/helpers.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 get_module_input_size has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def get_module_input_size(module: nn.Module) -> int:
    r"""Gets the input size of a module.

    This function works only for the module with a single input size.

Severity: Minor
Found in src/gravitorch/nn/utils/helpers.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 scheduled_profiler_with_tensorboard_trace has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def scheduled_profiler_with_tensorboard_trace(
Severity: Major
Found in src/gravitorch/utils/profilers/pytorch.py - About 1 hr to fix

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

    def find_tar_files(path: Path, recursive: bool = True) -> tuple[Path, ...]:
        r"""Finds the path of all the tar files in a given path.
    
        This function does not check if a path is a symbolic link so be
        careful if you are using a path with symbolic links.
    Severity: Minor
    Found in src/gravitorch/utils/path.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 _save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _save(self, engine: BaseEngine) -> None:
            r"""Saves the engine state dict in a PyTorch file.
    
            Args:
            ----
    Severity: Minor
    Found in src/gravitorch/handlers/engine_saver.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in src/gravitorch/rsrc/pytorch.py - About 50 mins to fix

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

      def is_loss_decreasing(
      Severity: Major
      Found in src/gravitorch/nn/utils/testing.py - About 50 mins to fix

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

        def is_loss_decreasing_with_adam(
        Severity: Major
        Found in src/gravitorch/nn/utils/testing.py - About 50 mins to fix

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

              def __init__(
          Severity: Major
          Found in src/gravitorch/models/metrics/vanilla.py - About 50 mins to fix

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

            def trunc_normal(
            Severity: Major
            Found in src/gravitorch/nn/init/normal.py - About 50 mins to fix

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

                  def __init__(
              Severity: Major
              Found in src/gravitorch/loops/evaluation/amp.py - About 50 mins to fix

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

                    def __init__(
                Severity: Major
                Found in src/gravitorch/rsrc/pytorch.py - About 50 mins to fix

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

                  def is_loss_decreasing_with_sgd(
                  Severity: Major
                  Found in src/gravitorch/nn/utils/testing.py - About 50 mins to fix

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

                        def __init__(
                    Severity: Major
                    Found in src/gravitorch/loops/training/amp.py - About 50 mins to fix

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

                          def __init__(
                      Severity: Minor
                      Found in src/gravitorch/loops/training/vanilla.py - About 45 mins to fix

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

                            def __init__(
                        Severity: Minor
                        Found in src/gravitorch/data/datacreators/hypercube.py - About 45 mins to fix

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

                          def asinh_barron_robust_loss(
                          Severity: Minor
                          Found in src/gravitorch/nn/functional/barron_loss.py - About 45 mins to fix

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

                                def __init__(
                            Severity: Minor
                            Found in src/gravitorch/nn/init/normal.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language