Erdnaxela3/bioptim_gui

View on GitHub

Showing 18 of 105 total issues

File pike_acrobatics_variables.py has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import numpy as np

from bioptim_gui_api.acrobatics_ocp.variables.variable_computers.straight_acrobatics_variables import (
    StraightAcrobaticsVariables,
)

    File straight_acrobatics_variables.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import numpy as np
    
    from bioptim_gui_api.acrobatics_ocp.variables.utils import maximum_fig_arms_angle
    from bioptim_gui_api.utils.format_utils import invert_min_max
    from bioptim_gui_api.variables.misc.variables_utils import define_loose_bounds, LooseValue

      Function plot_solutions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def plot_solutions(pkl_paths: list[str], variable: str = "q") -> None:
          assert len(pkl_paths) != 0
      
          with open(pkl_paths[0], "rb") as f:
              o = pkl.load(f)
      Severity: Minor
      Found in gui/graph_multiple_sols.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 get_q_bounds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_q_bounds(cls, half_twists: list, prefer_left: bool) -> dict:
              nb_somersaults = len(half_twists)
              is_forward = sum(half_twists) % 2 != 0
              x_bounds = []
      
      

      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 closest_distance_between_lines has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def closest_distance_between_lines():
          # adapté de https://stackoverflow.com/questions/2824478/shortest-distance-between-two-line-segments
      
          a0 = cas.SX.sym("a0", 3, 1)
          b0 = cas.SX.sym("b0", 3, 1)

        Function custom_noncrossing_const has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def custom_noncrossing_const(
        Severity: Major
        Found in api/bioptim_gui_api/acrobatics_ocp/code_generation/custom_penalty_fcn.py - About 50 mins to fix

          Function custom_noncrossing_obj has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def custom_noncrossing_obj(
          Severity: Major
          Found in api/bioptim_gui_api/acrobatics_ocp/code_generation/custom_penalty_fcn.py - About 50 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if phase != 0:
                                    axs[dof].vlines(
                                        t_start,
                                        bound[0],
                                        phases_bound[phase - 1][2],
            Severity: Major
            Found in gui/graph_multiple_sols.py - About 45 mins to fix

              Function _fill_position_phase has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _fill_position_phase(cls, x_bounds: list, i: int, half_twists: list) -> None:
                      # acrobatics starts with pike
                      if len(x_bounds) == 1:
                          x_bounds[0]["min"][:, 0] = [0] * cls.nb_q
                          x_bounds[0]["max"][:, 0] = [0] * cls.nb_q

              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 prepare_multi_start has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def prepare_multi_start(

                Function register_put_objective_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def register_put_objective_type(self):
                        @self.router.put("/{phase_index}/objectives/{objective_index}/objective_type", response_model=dict)
                        def put_objective_type(phase_index: int, objective_index: int, objective_type: ObjectiveTypeRequest):
                            phases_info = self.data.read_data("phases_info")
                            objective = phases_info[phase_index]["objectives"][objective_index]

                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 _fill_twist_phase has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _fill_twist_phase(cls, x_bounds: list, i: int, half_twists: list, is_last_somersault: bool) -> None:
                        nb_somersaults = len(half_twists)
                        for b in 0, 1, 2:
                            x_bounds[-1]["min"][:, b] = x_bounds[-2]["min"][:, 2]
                            x_bounds[-1]["max"][:, b] = x_bounds[-2]["max"][:, 2]

                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 adapt_dynamics has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def adapt_dynamics(phase: dict, dynamics: str) -> None:
                    control_names = DefaultVariablesConfig.dynamics_control.values()
                    control = DefaultVariablesConfig.dynamics_control[dynamics]
                
                    for argument in objective_key_arguments_iterator(phase):
                Severity: Minor
                Found in api/bioptim_gui_api/acrobatics_ocp/misc/dynamics_updating.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 objective_key_arguments_iterator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def objective_key_arguments_iterator(phase: dict) -> dict:
                    """
                    Iterates over the arguments of the objectives of the given phase
                
                    Parameters
                Severity: Minor
                Found in api/bioptim_gui_api/acrobatics_ocp/misc/dynamics_updating.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 get_dofs_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_dofs_name(nb_q):
                    # vanilla, with vision, with spine, with spine and vision
                    straight_nb_q = [10, 14, 22, 26]
                    pike_nb_q = [16, 20, 28, 32]
                    tuck_nb_q = [17, 21, 29, 33]
                Severity: Minor
                Found in gui/graph_multiple_sols.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 register_put_nb_somersaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def register_put_nb_somersaults(self):
                        @self.router.put("/nb_somersaults", response_model=NbSomersaultsResponse)
                        def update_nb_somersaults(nb_somersaults: NbSomersaultsRequest):
                            """
                            Append or pop the half_twists list

                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 var_bounds_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def var_bounds_list(data: dict, variable_name: str, var_type: BioptimVariable) -> list[dict]:
                    """
                    Return the list of all phases bounds (min and max) and interpolation type for the given variable
                
                    Parameters
                Severity: Minor
                Found in api/bioptim_gui_api/acrobatics_ocp/variables/utils.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 var_initial_guess_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def var_initial_guess_list(data: dict, variable_name: str, var_type: BioptimVariable) -> list[dict]:
                    """
                    Return the list of all phases initial guess and interpolation type for the given variable
                
                    Parameters
                Severity: Minor
                Found in api/bioptim_gui_api/acrobatics_ocp/variables/utils.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

                Severity
                Category
                Status
                Source
                Language