MushroomRL/mushroom-rl

View on GitHub

Showing 119 of 411 total issues

File dataset.py has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import numpy as np

from collections import defaultdict

import torch
Severity: Minor
Found in mushroom_rl/core/dataset.py - About 7 hrs to fix

    File viewer.py has 478 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import os
    import glfw
    import mujoco
    import time
    import collections
    Severity: Minor
    Found in mushroom_rl/utils/mujoco/viewer.py - About 7 hrs to fix

      File replay_memory.py has 455 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import numpy as np
      import torch
      
      from mushroom_rl.core import DatasetInfo, Dataset, Serializable
      from mushroom_rl.rl_utils.parameters import to_parameter
      Severity: Minor
      Found in mushroom_rl/rl_utils/replay_memory.py - About 6 hrs to fix

        Dataset has 42 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Dataset(Serializable):
            def __init__(self, dataset_info, n_steps=None, n_episodes=None):
                assert (n_steps is not None and n_episodes is None) or (n_steps is None and n_episodes is not None)
        
                self._array_backend = ArrayBackend.get_array_backend(dataset_info.backend)
        Severity: Minor
        Found in mushroom_rl/core/dataset.py - About 5 hrs to fix

          Function create_sim_state has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_sim_state(self):
                  data_obs = list()
          
                  self._contacts.compute_contacts()
          
          
          Severity: Minor
          Found in mushroom_rl/utils/pybullet/index_map.py - About 4 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 reset has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def reset(self, mask=None):
                  policy_states = None
                  if self.policy_state_shape is None:
                      if mask is None:
                          for policy in self._policy_vector:
          Severity: Minor
          Found in mushroom_rl/policy/vector_policy.py - About 4 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 predict has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def predict(self, *z, idx=None, prediction=None, compute_variance=False,
                          **predict_params):
                  """
                  Predict.
          
          
          Severity: Minor
          Found in mushroom_rl/approximators/ensemble.py - About 3 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 viewer.py has 329 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import os
          if 'PYGAME_HIDE_SUPPORT_PROMPT' not in os.environ:
              os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
          
          import pygame
          Severity: Minor
          Found in mushroom_rl/utils/viewer.py - About 3 hrs to fix

            File array_backend.py has 325 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from collections import deque
            import numpy as np
            import torch
            
            from mushroom_rl.utils.torch import TorchUtils
            Severity: Minor
            Found in mushroom_rl/core/array_backend.py - About 3 hrs to fix

              File gaussian.py has 313 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import numpy as np
              from .distribution import Distribution
              from scipy.stats import multivariate_normal
              from scipy.optimize import minimize
              
              
              Severity: Minor
              Found in mushroom_rl/distributions/gaussian.py - About 3 hrs to fix

                ArrayBackend has 29 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class ArrayBackend(object):
                
                    @staticmethod
                    def get_backend_name():
                        raise NotImplementedError
                Severity: Minor
                Found in mushroom_rl/core/array_backend.py - About 3 hrs to fix

                  Function add has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def add(self, dataset, n_steps_return=1, gamma=1.):
                          """
                          Add elements to the replay memory.
                  
                          Args:
                  Severity: Minor
                  Found in mushroom_rl/rl_utils/replay_memory.py - About 3 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 add has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def add(self, dataset, priority, n_steps_return, gamma):
                          """
                          Add elements to the tree.
                  
                          Args:
                  Severity: Minor
                  Found in mushroom_rl/rl_utils/replay_memory.py - About 3 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 render has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def render(self, data, record):
                          """
                          Main rendering function.
                  
                          Args:
                  Severity: Minor
                  Found in mushroom_rl/utils/mujoco/viewer.py - About 3 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 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def reward(self, state, action, next_state, absorbing):
                          puck_pos, puck_vel, _ = self.get_puck(next_state)
                          puck_pos = puck_pos[:2]
                          puck_vel = puck_vel[:2]
                          ee_pos = self.get_ee()[0][:2]
                  Severity: Minor
                  Found in mushroom_rl/environments/mujoco_envs/air_hockey/prepare.py - About 3 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 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def reward(self, state, action, next_state, absorbing):
                          puck_pos = self.get_sim_state(next_state, "puck", PyBulletObservationType.BODY_POS)[:2]
                          puck_vel = self.get_sim_state(next_state, "puck", PyBulletObservationType.BODY_LIN_VEL)[:2]
                          ee_pos = self.get_sim_state(next_state, "planar_robot_1/link_striker_ee",
                                                      PyBulletObservationType.LINK_POS)[:2]
                  Severity: Minor
                  Found in mushroom_rl/environments/pybullet_envs/air_hockey/prepare.py - About 3 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 keyboard has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def keyboard(self, window, key, scancode, act, mods):
                          """
                          Keyboard callback for glfw.
                  
                          Args:
                  Severity: Minor
                  Found in mushroom_rl/utils/mujoco/viewer.py - About 3 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

                  Consider simplifying this complex logical expression.
                  Open

                      if basis_list is not None and tilings is None and tensor_list is None and n_outputs is None:
                          return BasisFeatures(basis_list)
                      elif basis_list is None and tilings is not None and tensor_list is None and n_outputs is None:
                          return TilesFeatures(tilings)
                      elif basis_list is None and tilings is None and tensor_list is not None and n_outputs is None:
                  Severity: Critical
                  Found in mushroom_rl/features/features.py - About 3 hrs to fix

                    Function save_zip has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def save_zip(self, zip_file, full_save, folder=''):
                            """
                            Serialize and save the agent to the given path on disk.
                    
                            Args:
                    Severity: Minor
                    Found in mushroom_rl/core/serialization.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 load_zip has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def load_zip(cls, zip_file, folder=''):
                            config_path = Serializable._append_folder(folder, 'config')
                    
                            try:
                                object_type, save_attributes, primitive_dictionary = \
                    Severity: Minor
                    Found in mushroom_rl/core/serialization.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

                    Severity
                    Category
                    Status
                    Source
                    Language