Kev1CO/cocofest

View on GitHub

Showing 132 of 200 total issues

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

    def extract_data_from_pickle(self, solution: str):
        with open(solution, "rb") as f:
            pickle_data = pickle.load(f)
        data = {}

Severity: Minor
Found in cocofest/result/plot.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 _sanity_check has 22 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _sanity_check(
Severity: Major
Found in cocofest/optimization/fes_ocp.py - About 2 hrs to fix

    File hmed2018_with_fatigue.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from typing import Callable
    
    from casadi import MX, vertcat
    import numpy as np
    
    
    Severity: Minor
    Found in cocofest/models/hmed2018_with_fatigue.py - About 2 hrs to fix

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

      class DingModelFrequency(FesModel):
          """
          This is a custom model of the Bioptim package. As CustomModel, some methods are mandatory and must be implemented.
          to make it work with bioptim.
      
      
      Severity: Minor
      Found in cocofest/models/ding2003.py - About 2 hrs to fix

        File ding2007_with_fatigue.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from typing import Callable
        
        from casadi import MX, vertcat
        import numpy as np
        
        
        Severity: Minor
        Found in cocofest/models/ding2007_with_fatigue.py - About 2 hrs to fix

          Function prepare_ocp has 21 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def prepare_ocp(
          Severity: Major
          Found in cocofest/optimization/fes_ocp_dynamics.py - About 2 hrs to fix

            File ding2003_with_fatigue.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from typing import Callable
            
            from casadi import MX, vertcat
            import numpy as np
            
            
            Severity: Minor
            Found in cocofest/models/ding2003_with_fatigue.py - About 2 hrs to fix

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

                  def extract_data_from_sol(self, solution: Solution):
                      data = {}
                      n_phase = solution.ocp.n_phases
                      width = 2 * np.pi / n_phase
                      radii = 1 / (solution.ocp.nlp[0].model.nb_muscles + 1)
              Severity: Minor
              Found in cocofest/result/plot.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 stimulation_detection has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def stimulation_detection(
                      self,
                      time,
                      stimulation_signal,
                      average_time_difference: float = None,
              Severity: Minor
              Found in data_process/force_from_c3d.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

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

              class FesModel(ABC):
                  @abstractmethod
                  def set_a_rest(self, model, a_rest: MX | float):
                      """
              
              
              Severity: Minor
              Found in cocofest/models/fes_model.py - About 2 hrs to fix

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

                    def _pulse_mode_settings(self):
                        if self.pulse_mode == "single":
                            step = self.final_time / self.n_stim
                            self.final_time_phase = (step,)
                            for i in range(self.n_stim):
                Severity: Minor
                Found in cocofest/integration/ivp_fes.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 ding2007.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from typing import Callable
                
                import numpy as np
                from casadi import MX, vertcat, exp
                
                
                Severity: Minor
                Found in cocofest/models/ding2007.py - About 2 hrs to fix

                  Function prepare_ocp has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def prepare_ocp(
                          biorbd_model_path: str,
                          bound_type: str = None,
                          bound_data: list = None,
                          fes_muscle_models: list[FesModel] = None,
                  Severity: Minor
                  Found in cocofest/optimization/fes_ocp_dynamics.py - About 1 hr to fix

                    Function _build_parameters has 15 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def _build_parameters(
                    Severity: Major
                    Found in cocofest/optimization/fes_ocp_dynamics.py - About 1 hr to fix

                      Function __init__ has 15 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def __init__(
                      Severity: Major
                      Found in cocofest/optimization/fes_ocp_nmpc_cyclic.py - About 1 hr to fix

                        Function fit_func_by_fourier_series_with_real_coeffs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def fit_func_by_fourier_series_with_real_coeffs(self, x, ab, mode="numpy"):
                                result = 0.0
                                a = ab[:, 0]
                                b = ab[:, 1]
                                if mode == "numpy":
                        Severity: Minor
                        Found in cocofest/fourier_approx.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 prepare_ocp has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def prepare_ocp(
                                biorbd_model_path: str,
                                bound_type: str = None,
                                bound_data: list = None,
                                fes_muscle_models: list[FesModel] = None,
                        Severity: Minor
                        Found in cocofest/optimization/fes_ocp_dynamics.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 _build_parameters has 14 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def _build_parameters(
                        Severity: Major
                        Found in cocofest/optimization/fes_ocp.py - About 1 hr to fix

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

                              def __init__(
                                  self,
                                  fes_parameters: dict = None,
                                  ivp_parameters: dict = None,
                              ):
                          Severity: Minor
                          Found in cocofest/integration/ivp_fes.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 _sanity_check_fes_models_inputs has 13 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def _sanity_check_fes_models_inputs(
                          Severity: Major
                          Found in cocofest/optimization/fes_ocp_dynamics.py - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language