takuseno/d3rlpy

View on GitHub

Showing 51 of 51 total issues

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

def play(
    model_path: str,
    env_id: Optional[str],
    env_header: Optional[str],
    n_episodes: int,
Severity: Minor
Found in d3rlpy/cli.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 record has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def record(
    model_path: str,
    env_id: Optional[str],
    env_header: Optional[str],
    out: str,
Severity: Minor
Found in d3rlpy/cli.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 compute_ensemble_q_function_target has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def compute_ensemble_q_function_target(
    forwarders: Union[
        Sequence[DiscreteQFunctionForwarder],
        Sequence[ContinuousQFunctionForwarder],
    ],
Severity: Minor
Found in d3rlpy/models/torch/q_functions/ensemble_q_function.py - About 45 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
        self,
        buffer: BufferProtocol,
        preprocessor: WriterPreprocessProtocol,
        observation_signature: Signature,
Severity: Minor
Found in d3rlpy/dataset/writers.py - About 45 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 fit_with_transition_picker has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def fit_with_transition_picker(
        self,
        episodes: Sequence[EpisodeBase],
        transition_picker: TransitionPickerProtocol,
    ) -> None:
Severity: Minor
Found in d3rlpy/preprocessing/action_scalers.py - About 45 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

Avoid deeply nested control flow statements.
Open

                    while True:
                        tuple_path = f"{key}_{i}_{j}"
                        if tuple_path in h5:
                            tuple_data.append(h5[tuple_path][()])
                        else:
Severity: Major
Found in d3rlpy/dataset/io.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        for j in range(len(serializedData[key])):
                            elm = serializedData[key][j]
                            h5.create_dataset(f"{key}_{i}_{j}", data=elm)
                    else:
    Severity: Major
    Found in d3rlpy/dataset/io.py - About 45 mins to fix

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

          def fit_with_transition_picker(
              self,
              episodes: Sequence[EpisodeBase],
              transition_picker: TransitionPickerProtocol,
          ) -> None:
      Severity: Minor
      Found in d3rlpy/preprocessing/observation_scalers.py - About 45 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 __call__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(
              self,
              algo: QLearningAlgoProtocol,
              dataset: ReplayBufferBase,
          ) -> float:
      Severity: Minor
      Found in d3rlpy/metrics/evaluators.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 append has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def append(
              self,
              observation: Observation,
              action: Union[int, NDArray],
              reward: Union[float, NDArray],
      Severity: Minor
      Found in d3rlpy/dataset/writers.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 __call__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(
              self,
              algo: QLearningAlgoProtocol,
              dataset: ReplayBufferBase,
          ) -> float:
      Severity: Minor
      Found in d3rlpy/metrics/evaluators.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              env: gym.Env[NDArray, int],
              noop_max: int = 30,
              frame_skip: int = 4,
      Severity: Minor
      Found in d3rlpy/envs/wrappers.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 __call__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(
              self,
              algo: QLearningAlgoProtocol,
              dataset: ReplayBufferBase,
          ) -> float:
      Severity: Minor
      Found in d3rlpy/metrics/evaluators.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 from_numpy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_numpy(
              cls,
              inpt: TransformerInput,
              context_size: int,
              device: str,
      Severity: Minor
      Found in d3rlpy/algos/transformer/inputs.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

      Avoid too many return statements within this function.
      Open

              return GEGLU()
      Severity: Major
      Found in d3rlpy/models/utility.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return lam * min_values + (1.0 - lam) * max_values
        Severity: Major
        Found in d3rlpy/models/torch/q_functions/ensemble_q_function.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return get_d4rl(
          Severity: Major
          Found in d3rlpy/datasets.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return get_d4rl(
            Severity: Major
            Found in d3rlpy/datasets.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return nn.Identity()
              Severity: Major
              Found in d3rlpy/models/utility.py - About 30 mins to fix

                Function unfreeze has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def unfreeze(self) -> None:
                        for v in asdict_without_copy(self).values():
                            if isinstance(v, nn.Module):
                                for p in v.parameters():
                                    p.requires_grad = True
                Severity: Minor
                Found in d3rlpy/torch_utility.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

                Severity
                Category
                Status
                Source
                Language