MushroomRL/mushroom-rl

View on GitHub

Showing 119 of 411 total issues

PyBullet has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class PyBullet(Environment):
    """
    Class to create a Mushroom environment using the PyBullet simulator.

    """
Severity: Minor
Found in mushroom_rl/environments/pybullet.py - About 2 hrs to fix

    NumpyBackend has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class NumpyBackend(ArrayBackend):
        @staticmethod
        def get_backend_name():
            return 'numpy'
    
    
    Severity: Minor
    Found in mushroom_rl/core/array_backend.py - About 2 hrs to fix

      TorchBackend has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class TorchBackend(ArrayBackend):
      
          @staticmethod
          def get_backend_name():
              return 'torch'
      Severity: Minor
      Found in mushroom_rl/core/array_backend.py - About 2 hrs to fix

        Function __init__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, model, dt, width=1920, height=1080, start_paused=False,
                         custom_render_callback=None, record=False, camera_params=None,
                         default_camera_mode="static", hide_menu_on_startup=None,
                         geom_group_visualization_on_startup=None, headless=False):
                """
        Severity: Minor
        Found in mushroom_rl/utils/mujoco/viewer.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

        NumpyDataset has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class NumpyDataset(Serializable):
            def __init__(self, state_type, state_shape, action_type, action_shape, reward_shape, flag_shape,
                         policy_state_shape, mask_shape):
        
                self._state_type = state_type
        Severity: Minor
        Found in mushroom_rl/core/_impl/numpy_dataset.py - About 2 hrs to fix

          TorchDataset has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class TorchDataset(Serializable):
              def __init__(self, state_type, state_shape, action_type, action_shape, reward_shape, flag_shape,
                           policy_state_shape, mask_shape, device=None):
          
                  self._device = TorchUtils.get_device(device)
          Severity: Minor
          Found in mushroom_rl/core/_impl/torch_dataset.py - About 2 hrs to fix

            ListDataset has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class ListDataset(Serializable):
                def __init__(self, is_stateful, is_vectorized):
                    self._dataset = list()
                    self._policy_dataset = list()
                    self._is_stateful = is_stateful
            Severity: Minor
            Found in mushroom_rl/core/_impl/list_dataset.py - About 2 hrs to fix

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

                  def _process_observations(self):
                      low = list()
                      high = list()
              
                      for name, obs_type in self.observation_map:
              Severity: Minor
              Found in mushroom_rl/utils/pybullet/index_map.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 __init__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __init__(self, mdp_info, obs_normalized=False, window_size=1000,
                               update_freq=10, show=True):
              
                      """
                      Constructor.
              Severity: Minor
              Found in mushroom_rl/utils/callbacks/plot_dataset.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 reward has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def reward(self, state, action, next_state, absorbing):
                      r = 0
                      puck_pos = self.get_sim_state(next_state, "puck", PyBulletObservationType.BODY_POS)[:2]
              
                      puck_vel = self.get_sim_state(self._state, "puck", PyBulletObservationType.BODY_LIN_VEL)[:2]
              Severity: Minor
              Found in mushroom_rl/environments/pybullet_envs/air_hockey/hit.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

              File gaussian_policy.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import numpy as np
              
              from .policy import ParametricPolicy
              from scipy.stats import multivariate_normal
              
              
              Severity: Minor
              Found in mushroom_rl/policy/gaussian_policy.py - About 2 hrs to fix

                Function __init__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(self, observation_spec, model, data, max_joint_velocity):
                        if len(observation_spec) == 0:
                            raise AttributeError("No Environment observations were specified. "
                                                 "Add at least one observation to the observation_spec.")
                
                
                Severity: Minor
                Found in mushroom_rl/utils/mujoco/observation_helper.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 _env_worker has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                def _env_worker(remote, env_class, use_generator, args, kwargs):
                
                    if use_generator:
                        env = env_class.generate(*args, **kwargs)
                    else:
                Severity: Minor
                Found in mushroom_rl/core/multiprocess_environment.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 fit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    def fit(self, dataset):
                        for _ in trange(self._n_iterations(), dynamic_ncols=True, disable=self._quiet, leave=False):
                            state = list()
                            action = list()
                            reward = list()
                Severity: Minor
                Found in mushroom_rl/algorithms/value/batch_td/double_fqi.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 is_absorbing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def is_absorbing(self, state):
                        if super().is_absorbing(state):
                            return True
                        if self.sub_problem == "side":
                            if self.has_hit:
                Severity: Minor
                Found in mushroom_rl/environments/mujoco_envs/air_hockey/prepare.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 is_absorbing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def is_absorbing(self, state):
                        if super().is_absorbing(state):
                            return True
                        if self.sub_problem == "side":
                            if self.has_hit:
                Severity: Minor
                Found in mushroom_rl/environments/pybullet_envs/air_hockey/prepare.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 _assert_camera_params has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _assert_camera_params(self, camera_params):
                        """
                        Asserts if the provided camera parameters are valid or not. Also, if
                        properties of some camera types are not specified, the default parameters
                        are used.
                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 episode_start_vectorized has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def episode_start_vectorized(self, initial_states, episode_info, start_mask):
                        n_envs = len(start_mask)
                        if not isinstance(self.policy, VectorPolicy):
                            self.policy = VectorPolicy(self.policy, n_envs)
                        elif len(self.policy) != n_envs:

                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 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(self, name, horizon=None, gamma=0.99, wrappers=None, wrappers_args=None,
                                 **env_args):
                        """
                        Constructor.
                
                
                Severity: Minor
                Found in mushroom_rl/environments/gym_env.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 a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(self, name, horizon=None, gamma=0.99, headless = False, wrappers=None, wrappers_args=None,
                                 **env_args):
                        """
                        Constructor.
                
                
                Severity: Minor
                Found in mushroom_rl/environments/gymnasium_env.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

                Severity
                Category
                Status
                Source
                Language