Kev1CO/cocofest

View on GitHub

Showing 200 of 200 total issues

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

            if parameter_list[i][counter] == [100, 100]:
                c_ocp_time = [single_ocp_time][i][counter]
                c_integration_time = [single_computations_time][i][counter]
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 95..97
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 99..101

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

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

            if parameter_list[i][counter] == [100, 39]:
                b_ocp_time = [single_ocp_time][i][counter]
                b_integration_time = [single_computations_time][i][counter]
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 95..97
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 103..105

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

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

    objective_functions.add(
        ObjectiveFcn.Mayer.MINIMIZE_STATE,
        key="q",
        index=[0],
        node=Node.ALL,
cocofest/examples/dynamics/intensity_optimization_hold_position.py on lines 35..40

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

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

axs.scatter(
    100,
    39,
    color="black",
    label="      " + str(round(b_ocp_time, 3)) + "                   " + str(round(b_integration_time, 3)),
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 190..194
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 208..212

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

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

axs.scatter(
    1,
    1,
    color="blue",
    label="      " + str(round(a_ocp_time, 3)) + "                   " + str(round(a_integration_time, 3)),
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 199..203
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 208..212

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

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

axs.scatter(
    100,
    100,
    color="green",
    label="      " + str(round(c_ocp_time, 3)) + "                   " + str(round(c_integration_time, 3)),
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 190..194
cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 199..203

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

objective_functions.add(
    ObjectiveFcn.Mayer.MINIMIZE_STATE,
    key="qdot",
    index=[0, 1],
    node=Node.END,
cocofest/examples/dynamics/minimize_fatigue/pulse_duration_optimization_minimize_fatigue.py on lines 22..30
cocofest/examples/dynamics/minimize_fatigue/pulse_intensity_optimization_minimize_fatigue.py on lines 22..30

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

objective_functions.add(
    ObjectiveFcn.Mayer.MINIMIZE_STATE,
    key="qdot",
    index=[0, 1],
    node=Node.END,
cocofest/examples/dynamics/minimize_fatigue/frequecy_optimization_minimize_fatigue.py on lines 25..33
cocofest/examples/dynamics/minimize_fatigue/pulse_duration_optimization_minimize_fatigue.py on lines 22..30

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

objective_functions.add(
    ObjectiveFcn.Mayer.MINIMIZE_STATE,
    key="qdot",
    index=[0, 1],
    node=Node.END,
cocofest/examples/dynamics/minimize_fatigue/frequecy_optimization_minimize_fatigue.py on lines 25..33
cocofest/examples/dynamics/minimize_fatigue/pulse_intensity_optimization_minimize_fatigue.py on lines 22..30

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

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

                Severity
                Category
                Status
                Source
                Language