Kev1CO/cocofest

View on GitHub

Showing 200 of 200 total issues

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

    def __init__(
Severity: Minor
Found in cocofest/models/dynamical_model.py - About 35 mins to fix

    Function force_at_node_in_ocp has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def force_at_node_in_ocp(time, force, n_shooting, final_time_phase, sparse=None):
    Severity: Minor
    Found in cocofest/identification/identification_method.py - About 35 mins to fix

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

      def prepare_ocp(
      Severity: Minor
      Found in cocofest/examples/dynamics/cycling/cycling_muscle_driven.py - About 35 mins to fix

        Function _set_bounds has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _set_bounds(model=None, n_stim=None, n_shooting=None, force_tracking=None, discontinuity_in_ocp=None):
        Severity: Minor
        Found in cocofest/optimization/fes_identification_ocp.py - About 35 mins to fix

          Function _build_phase_time has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _build_phase_time(final_time, n_stim, pulse_mode, time_min, time_max):
          Severity: Minor
          Found in cocofest/optimization/fes_ocp.py - About 35 mins to fix

            Function configure_cross_bridges has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def configure_cross_bridges(
            Severity: Minor
            Found in cocofest/models/state_configue.py - About 35 mins to fix

              Function get_initial_guess has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def get_initial_guess(biorbd_model_path: str, final_time: int, n_stim: int, n_shooting: int, objective: dict) -> dict:
              Severity: Minor
              Found in cocofest/dynamics/warm_start.py - About 35 mins to fix

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

                    def remove_duplicates(self, time):
                        states = self.sol.decision_states(to_merge=[SolutionMerge.PHASES, SolutionMerge.NODES])
                        vals, idx_start, count = np.unique(time, return_counts=True, return_index=True)
                        time = time[idx_start]
                        state_keys = states.keys()
                Severity: Minor
                Found in cocofest/result/pickle.py - About 35 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 dynamics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def dynamics(
                        time: MX,
                        states: MX,
                        controls: MX,
                        parameters: MX,
                Severity: Minor
                Found in cocofest/models/ding2007.py - About 35 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_intensity_parameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_intensity_parameters(nlp, parameters: ParameterList, muscle_name: str = None) -> MX:
                        """
                        Get the nlp list of intensity parameters
                
                        Parameters
                Severity: Minor
                Found in cocofest/models/hmed2018.py - About 35 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 dynamics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def dynamics(
                        time: MX,
                        states: MX,
                        controls: MX,
                        parameters: MX,
                Severity: Minor
                Found in cocofest/models/ding2007_with_fatigue.py - About 35 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_pulse_duration_parameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_pulse_duration_parameters(nlp, parameters: ParameterList, muscle_name: str = None) -> MX:
                        """
                        Get the nlp list of pulse_duration parameters
                
                        Parameters
                Severity: Minor
                Found in cocofest/models/ding2007.py - About 35 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

                    with open("/result_file/pulse_apparition_" + pickle_file_list[i], "wb") as file:
                        pickle.dump(dictionary, file)
                cocofest/examples/dynamics/reaching_task/reaching_task_intensity_optimization.py on lines 123..124

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

                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

                    with open("/result_file/pulse_intensity_" + pickle_file_list[i], "wb") as file:
                        pickle.dump(dictionary, file)
                cocofest/examples/dynamics/reaching_task/reaching_task_frequency_optimization.py on lines 116..117

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

                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

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

                    def cn_sum_fun(self, r0: MX | float, t: MX, t_stim_prev: list[MX]) -> MX | float:
                        """
                        Parameters
                        ----------
                        r0: MX | float
                Severity: Minor
                Found in cocofest/models/ding2003.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 cn_sum_fun has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def cn_sum_fun(
                        self, r0: MX | float, t: MX, t_stim_prev: list[MX] = None, intensity_stim: list[MX] = None
                    ) -> MX | float:
                        """
                        Parameters
                Severity: Minor
                Found in cocofest/models/hmed2018.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 configure_all_muscle_states has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def configure_all_muscle_states(self, muscles_dynamics_model, ocp, nlp):
                        state_name_list = []
                        for muscle_dynamics_model in muscles_dynamics_model:
                            for state_key in muscle_dynamics_model.name_dof:
                                if state_key in self.state_dictionary.keys():
                Severity: Minor
                Found in cocofest/models/state_configue.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 node_shooting_list_creation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def node_shooting_list_creation(stim, stimulated_n_shooting):
                    """
                    Creates a list of node shooting points.
                
                    Parameters
                Severity: Minor
                Found in cocofest/identification/identification_method.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_initial_guess_from_ocp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_initial_guess_from_ocp(self, ocp):
                        """
                        Build a state, control, parameters and stochastic initial guesses for each phases from a given ocp
                        """
                        x = InitialGuessList()
                Severity: Minor
                Found in cocofest/integration/ivp_fes.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 from_frequency_and_final_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def from_frequency_and_final_time(
                        cls,
                        fes_parameters: dict = None,
                        ivp_parameters: dict = None,
                    ):
                Severity: Minor
                Found in cocofest/integration/ivp_fes.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