Kev1CO/cocofest

View on GitHub

Showing 200 of 200 total issues

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

for i in range(n_stim):
    objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=1, quadratic=True, phase=i)
cocofest/examples/dynamics/cycling/cycling_fes_driven.py on lines 26..27
cocofest/examples/dynamics/frequency_optimization_musculoskeletal_dynamic_2dof.py on lines 19..20
cocofest/examples/dynamics/intensity_optimization_cycling_multi_muscle.py on lines 30..31
cocofest/examples/dynamics/minimize_fatigue/frequecy_optimization_minimize_fatigue.py on lines 35..36
cocofest/examples/getting_started/frequency_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_intensity_optimization_musculoskeletal_dynamic.py on lines 19..20

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

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 7 locations. Consider refactoring.
Open

for i in range(n_stim):
    objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=1, quadratic=True, phase=i)
cocofest/examples/dynamics/cycling/cycling_fes_driven.py on lines 26..27
cocofest/examples/dynamics/frequency_optimization_musculoskeletal_dynamic_2dof.py on lines 19..20
cocofest/examples/dynamics/minimize_fatigue/frequecy_optimization_minimize_fatigue.py on lines 35..36
cocofest/examples/getting_started/frequency_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_duration_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_intensity_optimization_musculoskeletal_dynamic.py on lines 19..20

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

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 7 locations. Consider refactoring.
Open

for i in range(n_stim):
    objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=10000, quadratic=True, phase=i)
cocofest/examples/dynamics/cycling/cycling_fes_driven.py on lines 26..27
cocofest/examples/dynamics/frequency_optimization_musculoskeletal_dynamic_2dof.py on lines 19..20
cocofest/examples/dynamics/intensity_optimization_cycling_multi_muscle.py on lines 30..31
cocofest/examples/getting_started/frequency_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_duration_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_intensity_optimization_musculoskeletal_dynamic.py on lines 19..20

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

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 7 locations. Consider refactoring.
Open

for i in range(n_stim):
    objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=1, quadratic=True, phase=i)
cocofest/examples/dynamics/cycling/cycling_fes_driven.py on lines 26..27
cocofest/examples/dynamics/frequency_optimization_musculoskeletal_dynamic_2dof.py on lines 19..20
cocofest/examples/dynamics/intensity_optimization_cycling_multi_muscle.py on lines 30..31
cocofest/examples/dynamics/minimize_fatigue/frequecy_optimization_minimize_fatigue.py on lines 35..36
cocofest/examples/getting_started/pulse_duration_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_intensity_optimization_musculoskeletal_dynamic.py on lines 19..20

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

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 7 locations. Consider refactoring.
Open

    for i in range(n_stim):
        objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=100, quadratic=True, phase=i)
Severity: Major
Found in cocofest/examples/dynamics/cycling/cycling_fes_driven.py and 6 other locations - About 50 mins to fix
cocofest/examples/dynamics/frequency_optimization_musculoskeletal_dynamic_2dof.py on lines 19..20
cocofest/examples/dynamics/intensity_optimization_cycling_multi_muscle.py on lines 30..31
cocofest/examples/dynamics/minimize_fatigue/frequecy_optimization_minimize_fatigue.py on lines 35..36
cocofest/examples/getting_started/frequency_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_duration_optimization_musculoskeletal_dynamic.py on lines 19..20
cocofest/examples/getting_started/pulse_intensity_optimization_musculoskeletal_dynamic.py on lines 19..20

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

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 3 locations. Consider refactoring.
Open

stimulation_single = np.concatenate((np.array([0]), np.cumsum(np.array(ivp.final_time_phase))))
Severity: Major
Found in cocofest/examples/getting_started/pulse_mode_example.py and 2 other locations - About 50 mins to fix
cocofest/examples/getting_started/pulse_mode_example.py on lines 47..47
cocofest/examples/getting_started/pulse_mode_example.py on lines 63..63

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

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 3 locations. Consider refactoring.
Open

stimulation_doublet = np.concatenate((np.array([0]), np.cumsum(np.array(ivp.final_time_phase))))
Severity: Major
Found in cocofest/examples/getting_started/pulse_mode_example.py and 2 other locations - About 50 mins to fix
cocofest/examples/getting_started/pulse_mode_example.py on lines 28..28
cocofest/examples/getting_started/pulse_mode_example.py on lines 63..63

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

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 3 locations. Consider refactoring.
Open

stimulation_triplet = np.concatenate((np.array([0]), np.cumsum(np.array(ivp.final_time_phase))))
Severity: Major
Found in cocofest/examples/getting_started/pulse_mode_example.py and 2 other locations - About 50 mins to fix
cocofest/examples/getting_started/pulse_mode_example.py on lines 28..28
cocofest/examples/getting_started/pulse_mode_example.py on lines 47..47

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

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

Avoid deeply nested control flow statements.
Open

                        for k in range(1, len(time[j])):
                            if counter == 9:
                                counter = 0
                            else:
                                remove_list.append(k)
Severity: Major
Found in data_process/force_from_c3d.py - About 45 mins to fix

    Function system_dynamics has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def system_dynamics(
    Severity: Minor
    Found in cocofest/models/ding2003.py - About 45 mins to fix

      Function system_dynamics has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def system_dynamics(
      Severity: Minor
      Found in cocofest/models/fes_model.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for k in range(1, len(sliced_time[j])):
                                    if counter == 9:
                                        counter = 0
                                    else:
                                        remove_list.append(k)
        Severity: Major
        Found in data_process/force_from_c3d.py - About 45 mins to fix

          Function inverse_kinematics_cycling has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def inverse_kinematics_cycling(
          Severity: Minor
          Found in cocofest/dynamics/inverse_kinematics_and_dynamics.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if isinstance(fixed_pulse_intensity, list):
                                        parameters_bounds.add(
                                            parameter_name,
                                            min_bound=np.array(fixed_pulse_intensity),
                                            max_bound=np.array(fixed_pulse_intensity),
            Severity: Major
            Found in cocofest/optimization/fes_ocp_dynamics.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for k in range(len(sliced_data)):
                                          remove_list = []
                                          counter = 0
                                          for m in range(1, len(sliced_data[k][j])):
                                              if counter == 9:
              Severity: Major
              Found in data_process/force_from_c3d.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if saving_pickle_path_list[:-4] == ".pkl":
                                            save_pickle_path = saving_pickle_path_list[:-4] + "_" + str(i) + ".pkl"
                                        else:
                                            save_pickle_path = saving_pickle_path_list[0] + "_" + str(i) + ".pkl"
                                    else:
                Severity: Major
                Found in data_process/force_from_c3d.py - About 45 mins to fix

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

                      def muscles_joint_torque(
                          time: MX | SX,
                          states: MX | SX,
                          controls: MX | SX,
                          parameters: MX | SX,
                  Severity: Minor
                  Found in cocofest/models/dynamical_model.py - About 45 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

                  Avoid deeply nested control flow statements.
                  Open

                                          for k in range(len(peaks)):
                                              plt.plot(time[peaks[k]], filtered_6d_force[0][peaks[k]], "x")
                                          if down_sample:
                  Severity: Major
                  Found in data_process/force_from_c3d.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if down_sample:
                                                for k in range(len(sliced_time)):
                                                    plt.plot(temp_time[k], temp_data[0][k])
                                            plt.show()
                    Severity: Major
                    Found in data_process/force_from_c3d.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for k in range(len(filtered_6d_force)):
                                                  remove_list = []
                                                  counter = 0
                                                  for m in range(1, len(filtered_6d_force[k][j])):
                                                      if counter == 9:
                      Severity: Major
                      Found in data_process/force_from_c3d.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language