takuseno/d3rlpy

View on GitHub

Showing 52 of 52 total issues

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 GEGLU()
    Severity: Major
    Found in d3rlpy/models/utility.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

        Avoid too many return statements within this function.
        Open

                return get_d4rl(
        Severity: Major
        Found in d3rlpy/datasets.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

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

          def create_activation(activation_type: str) -> nn.Module:
              if activation_type == "relu":
                  return nn.ReLU()
              elif activation_type == "gelu":
                  return nn.GELU()
          Severity: Minor
          Found in d3rlpy/models/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

          Function fit_with_transition_picker has a Cognitive Complexity of 6 (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 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 evaluate_transformer_with_environment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def evaluate_transformer_with_environment(
              algo: StatefulTransformerAlgoProtocol,
              env: GymEnv,
              n_trials: int = 10,
          ) -> float:
          Severity: Minor
          Found in d3rlpy/metrics/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

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

          def get_dataset(
              env_name: str,
              transition_picker: Optional[TransitionPickerProtocol] = None,
              trajectory_slicer: Optional[TrajectorySlicerProtocol] = None,
              render_mode: Optional[str] = None,
          Severity: Minor
          Found in d3rlpy/datasets.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_parameters_from_named_modules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def _get_parameters_from_named_modules(
              named_modules: Iterable[Tuple[str, nn.Module]]
          ) -> Sequence[nn.Parameter]:
              # retrieve unique set of parameters
              params_dict = {}
          Severity: Minor
          Found in d3rlpy/optimizers/optimizers.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 freeze has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def freeze(self) -> None:
                  for v in asdict_without_copy(self).values():
                      if isinstance(v, nn.Module):
                          for p in v.parameters():
                              p.requires_grad = False
          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

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

          def _process_device(value: DeviceArg) -> str:
              """Checks value and returns PyTorch target device.
          
              Returns:
                  str: target device.
          Severity: Minor
          Found in d3rlpy/base.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