takuseno/d3rlpy

View on GitHub

Showing 52 of 52 total issues

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

    def reset(self, **kwargs: Any) -> Tuple[NDArray, Dict[str, Any]]:
        # this condition is not included in the original code
        if self.game_over:
            _, info = self.env.reset(**kwargs)
        else:
Severity: Minor
Found in d3rlpy/envs/wrappers.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 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 get_atari has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def get_atari(
    env_name: str,
    num_stack: Optional[int] = None,
    sticky_action: bool = True,
    pre_stack: bool = False,
Severity: Minor
Found in d3rlpy/datasets.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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
        self,
        env: gymnasium.Env[Dict[str, NDArray], _ActType],
        observation_key: str = "observation",
        goal_key: str = "desired_goal",
Severity: Minor
Found in d3rlpy/envs/wrappers.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

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

    def create_discrete_q_function(
        observation_shape: Shape,
        action_size: int,
        encoder_factory: EncoderFactory,
        q_func_factory: QFunctionFactory,
    Severity: Minor
    Found in d3rlpy/models/builders.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 create_continuous_q_function has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_continuous_q_function(
        observation_shape: Shape,
        action_size: int,
        encoder_factory: EncoderFactory,
        q_func_factory: QFunctionFactory,
    Severity: Minor
    Found in d3rlpy/models/builders.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

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

          def get_gradients(self) -> Iterator[Tuple[str, Float32NDArray]]:
              for module_name, module in self.get_torch_modules().items():
                  for name, parameter in module.named_parameters():
                      if parameter.requires_grad and parameter.grad is not None:
                          yield f"{module_name}.{name}", parameter.grad.cpu().detach().numpy()
      Severity: Minor
      Found in d3rlpy/torch_utility.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

      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 __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 __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 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

      Avoid too many return statements within this function.
      Open

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