MushroomRL/mushroom-rl

View on GitHub
mushroom_rl/environments/pybullet_envs/air_hockey/prepare.py

Summary

Maintainability
B
5 hrs
Test Coverage
F
57%

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

Avoid too many return statements within this function.
Open

            return False
Severity: Major
Found in mushroom_rl/environments/pybullet_envs/air_hockey/prepare.py - About 30 mins to fix

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

        def _simulation_post_step(self):
            if not self.has_hit:
                collision_count = len(self.client.getContactPoints(self._model_map['puck'],
                                                                   self._indexer.link_map['planar_robot_1/'
                                                                                          'link_striker_ee'][0],
    Severity: Minor
    Found in mushroom_rl/environments/pybullet_envs/air_hockey/prepare.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

    There are no issues that match your filters.

    Category
    Status