MushroomRL/mushroom-rl

View on GitHub

Showing 119 of 411 total issues

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

    def get_view(self, index, copy=False):
        view = self.create_new_instance(self)

        if copy:
            view._states = np.empty_like(self._states)
Severity: Minor
Found in mushroom_rl/core/_impl/numpy_dataset.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 mouse_move has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def mouse_move(self, window, x_pos, y_pos):
        """
        Mouse mode callback for glfw.

        Args:
Severity: Minor
Found in mushroom_rl/utils/mujoco/viewer.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 _step has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _step(self, render, record, mask):
        """
        Single step.

        Args:
Severity: Minor
Found in mushroom_rl/core/vectorized_core.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 __init__ has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self, gamma=0.99, horizon=500, n_agents=1, env_noise=False, obs_noise=False, obs_delay=False,
                 torque_control=True, step_action_function=None, timestep=1 / 240., n_intermediate_steps=1,
                 debug_gui=False, table_boundary_terminate=False):
        """
        Constructor.
Severity: Minor
Found in mushroom_rl/environments/pybullet_envs/air_hockey/base.py - About 1 hr to fix

    Function __init__ has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self, gamma=0.99, horizon=120, env_noise=False, obs_noise=False, timestep=1 / 240.,
                     n_intermediate_steps=1, **viewer_params):
    
            """
            Constructor.
    Severity: Minor
    Found in mushroom_rl/environments/mujoco_envs/air_hockey/double.py - About 1 hr to fix

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

          def _set_camera(self):
              """
              Sets the camera mode to the current camera mode target. Allowed camera
              modes are "follow" in which the model is tracked, "static" that is a static
              camera at the default camera positon, and "top_static" that is a static
      Severity: Minor
      Found in mushroom_rl/utils/mujoco/viewer.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 convert has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def convert(cls, *arrays, to=None, backend=None):
              if to is None:
                  to = cls.get_backend_name()
              if backend is None:
                  backend = ArrayBackend.get_array_backend_from(arrays[0])
      Severity: Minor
      Found in mushroom_rl/core/array_backend.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 step has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def step(self, action):
              total_reward = 0.
              for i in range(self._skip):
                  obs, reward, absorbing, _, info = self.env.step(action)
                  if i == self._skip - 2:
      Severity: Minor
      Found in mushroom_rl/environments/gymnasium_atari.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 _process_actuation_spec has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _process_actuation_spec(self, actuation_spec):
              for name, mode in actuation_spec:
                  if name in self.joint_map:
                      data = self.joint_map[name] + (mode,)
                      self.action_data.append(data)
      Severity: Minor
      Found in mushroom_rl/utils/pybullet/index_map.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 predict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def predict(self, *z):
              """
              Predict the output of the table given an input.
      
              Args:
      Severity: Minor
      Found in mushroom_rl/approximators/table.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 reset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def reset(self, state=None):
              if state is None:
                  if self.random_init:
                      rand_state = np.random.uniform(-3, 3, size=self.A.shape[0])
                      self._state = self._bound(rand_state, self.info.observation_space.low, self.info.observation_space.high)
      Severity: Minor
      Found in mushroom_rl/environments/lqr.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_gae has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_gae(V, s, pi_h, ss, pi_hn, lengths, r, absorbing, last, gamma, lam):
              """
              Function to compute Generalized Advantage Estimation (GAE)
              and new value function target over a dataset.
      
      
      Severity: Minor
      Found in mushroom_rl/algorithms/actor_critic/deep_actor_critic/ppo_bptt.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 compute_indexes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_indexes(self, *args):
              x = self._concatenate(args)
      
              y = list()
      
      
      Severity: Minor
      Found in mushroom_rl/features/_implementations/tiles_features.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 forward has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def forward(self, state, action=None, get_quantiles=False):
              features = self._phi(state)
      
              a_quant = [self._quant[i](features) for i in range(self._n_output)]
              a_quant = torch.stack(a_quant, dim=1)
      Severity: Minor
      Found in mushroom_rl/algorithms/value/dqn/quantile_dqn.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 compute_gae has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def compute_gae(V, s, ss, r, absorbing, last, gamma, lam):
          """
          Function to compute Generalized Advantage Estimation (GAE)
          and new value function target over a dataset.
      
      
      Severity: Minor
      Found in mushroom_rl/rl_utils/value_functions.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, config_file, horizon=None, gamma=0.99, is_discrete=False,
                       width=None, height=None, debug_gui=False, verbose=False):
              """
              Constructor.
      
      
      Severity: Minor
      Found in mushroom_rl/environments/igibson_env.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 _set_horizon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _set_horizon(env, horizon):
      
              while not hasattr(env, '_max_episode_steps') and env.env != env.unwrapped:
                      env = env.env
      
      
      Severity: Minor
      Found in mushroom_rl/environments/gymnasium_env.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 get_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_state(self, data, name, o_type):
              """
              Get a single observation from data, given it's name and observation type. The ObservationType documentation
              describes the different returns in detail
              """
      Severity: Minor
      Found in mushroom_rl/utils/mujoco/observation_helper.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 get_view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_view(self, index, copy=False):
              view = self.create_new_instance(self)
      
              if isinstance(index, (int, slice)):
                  view._dataset = self._dataset[index]
      Severity: Minor
      Found in mushroom_rl/core/_impl/list_dataset.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

      Consider simplifying this complex logical expression.
      Open

                  if obs_type is PyBulletObservationType.BODY_POS \
                     or obs_type is PyBulletObservationType.BODY_LIN_VEL \
                     or obs_type is PyBulletObservationType.BODY_ANG_VEL:
                      model_id = self.model_map[name]
                      if obs_type is PyBulletObservationType.BODY_POS:
      Severity: Major
      Found in mushroom_rl/utils/pybullet/index_map.py - About 40 mins to fix
        Severity
        Category
        Status
        Source
        Language