MushroomRL/mushroom-rl

View on GitHub
mushroom_rl/utils/pybullet/index_map.py

Summary

Maintainability
D
2 days
Test Coverage
B
86%

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

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

    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:
                    n_dim = 7 if obs_type is PyBulletObservationType.BODY_POS else 3
                    low += [-np.inf] * n_dim
    Severity: Major
    Found in mushroom_rl/utils/pybullet/index_map.py - About 40 mins to fix

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

          def apply_control(self, action):
      
              i = 0
              for model_id, joint_id, mode in self.action_data:
                  u = action[i]
      Severity: Minor
      Found in mushroom_rl/utils/pybullet/index_map.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 _build_joint_and_link_maps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _build_joint_and_link_maps(self):
              for model_id in self.model_map.values():
                  for joint_id in range(self._client.getNumJoints(model_id)):
                      joint_data = self._client.getJointInfo(model_id, joint_id)
      
      
      Severity: Minor
      Found in mushroom_rl/utils/pybullet/index_map.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  if obs_type is PyBulletObservationType.BODY_POS \
                     or obs_type is PyBulletObservationType.BODY_LIN_VEL \
                     or obs_type is PyBulletObservationType.BODY_ANG_VEL:
                      n_dim = 7 if obs_type is PyBulletObservationType.BODY_POS else 3
                      low += [-np.inf] * n_dim
      Severity: Major
      Found in mushroom_rl/utils/pybullet/index_map.py and 1 other location - About 2 hrs to fix
      mushroom_rl/utils/pybullet/index_map.py on lines 151..156

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 58.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  elif obs_type is PyBulletObservationType.LINK_POS \
                          or obs_type is PyBulletObservationType.LINK_LIN_VEL \
                          or obs_type is PyBulletObservationType.LINK_ANG_VEL:
                      n_dim = 7 if obs_type is PyBulletObservationType.LINK_POS else 3
                      low += [-np.inf] * n_dim
      Severity: Major
      Found in mushroom_rl/utils/pybullet/index_map.py and 1 other location - About 2 hrs to fix
      mushroom_rl/utils/pybullet/index_map.py on lines 145..150

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 58.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  if mode is pybullet.POSITION_CONTROL:
                      kwargs = dict(targetPosition=u, maxVelocity=self._client.getJointInfo(model_id, joint_id)[11],
                                    force=self._client.getJointInfo(model_id, joint_id)[10])
      Severity: Major
      Found in mushroom_rl/utils/pybullet/index_map.py and 1 other location - About 1 hr to fix
      mushroom_rl/utils/pybullet/index_map.py on lines 89..91

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  elif mode is pybullet.VELOCITY_CONTROL:
                      kwargs = dict(targetVelocity=u, maxVelocity=self._client.getJointInfo(model_id, joint_id)[11],
                                    force=self._client.getJointInfo(model_id, joint_id)[10])
      Severity: Major
      Found in mushroom_rl/utils/pybullet/index_map.py and 1 other location - About 1 hr to fix
      mushroom_rl/utils/pybullet/index_map.py on lines 86..88

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  elif mode is pybullet.VELOCITY_CONTROL:
                      low.append(-joint_info[11])
                      high.append(joint_info[11])
      Severity: Minor
      Found in mushroom_rl/utils/pybullet/index_map.py and 1 other location - About 45 mins to fix
      mushroom_rl/utils/pybullet/index_map.py on lines 131..133

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  elif mode is pybullet.TORQUE_CONTROL:
                      low.append(-joint_info[10])
                      high.append(joint_info[10])
      Severity: Minor
      Found in mushroom_rl/utils/pybullet/index_map.py and 1 other location - About 45 mins to fix
      mushroom_rl/utils/pybullet/index_map.py on lines 128..130

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status