Kev1CO/cocofest

View on GitHub

Showing 200 of 200 total issues

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

            discontinuity_phase_list.append(
                len(global_model_stim_apparition_time[-1])
                if discontinuity_phase_list == []
                else discontinuity_phase_list[-1] + len(global_model_stim_apparition_time[-1])
Severity: Major
Found in cocofest/identification/identification_method.py and 1 other location - About 2 hrs to fix
cocofest/identification/identification_method.py on lines 141..144

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

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

            discontinuity_phase_list.append(
                len(global_model_stim_apparition_time[-1])
                if discontinuity_phase_list == []
                else discontinuity_phase_list[-1] + len(global_model_stim_apparition_time[-1])
Severity: Major
Found in cocofest/identification/identification_method.py and 1 other location - About 2 hrs to fix
cocofest/identification/identification_method.py on lines 48..51

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

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

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

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

        ik_qddot = np.array([np.gradient(ik_qdot[i], (1 / (n_frames))) for i in range(ik_qdot.shape[0])])
    cocofest/examples/dynamics/cycling/inverse_kinematics_cycling.py on lines 29..29

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

    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

        ik_qdot = np.array([np.gradient(ik_q[i], (1 / n_frames)) for i in range(ik_q.shape[0])])
    cocofest/examples/dynamics/cycling/inverse_kinematics_cycling.py on lines 30..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 50.

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

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

      plt.vlines(
          x=stimulation_doublet[:-1],
          ymin=max(force_doublet) - 30,
          ymax=max(force_doublet),
      Severity: Major
      Found in cocofest/examples/getting_started/pulse_mode_example.py and 2 other locations - About 1 hr to fix
      cocofest/examples/getting_started/pulse_mode_example.py on lines 72..75
      cocofest/examples/getting_started/pulse_mode_example.py on lines 90..93

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

      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

      plt.vlines(
          x=stimulation_triplet[:-1],
          ymin=max(force_triplet) - 30,
          ymax=max(force_triplet),
      Severity: Major
      Found in cocofest/examples/getting_started/pulse_mode_example.py and 2 other locations - About 1 hr to fix
      cocofest/examples/getting_started/pulse_mode_example.py on lines 72..75
      cocofest/examples/getting_started/pulse_mode_example.py on lines 81..84

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

      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

      plt.vlines(
          x=stimulation_single[:-1],
          ymin=max(force_single) - 30,
          ymax=max(force_single),
      Severity: Major
      Found in cocofest/examples/getting_started/pulse_mode_example.py and 2 other locations - About 1 hr to fix
      cocofest/examples/getting_started/pulse_mode_example.py on lines 81..84
      cocofest/examples/getting_started/pulse_mode_example.py on lines 90..93

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

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

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

          fes_muscle_models = [
              DingModelFrequencyWithFatigue(muscle_name="BIClong"),
              DingModelFrequencyWithFatigue(muscle_name="BICshort"),
              DingModelFrequencyWithFatigue(muscle_name="TRIlong"),
              DingModelFrequencyWithFatigue(muscle_name="TRIlat"),
          cocofest/examples/dynamics/reaching_task/reaching_task_intensity_optimization.py on lines 51..57
          cocofest/examples/dynamics/reaching_task/reaching_task_pulse_duration_optimization.py on lines 50..56

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

          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

          fes_muscle_models = [
              DingModelPulseDurationFrequencyWithFatigue(muscle_name="BIClong"),
              DingModelPulseDurationFrequencyWithFatigue(muscle_name="BICshort"),
              DingModelPulseDurationFrequencyWithFatigue(muscle_name="TRIlong"),
              DingModelPulseDurationFrequencyWithFatigue(muscle_name="TRIlat"),
          cocofest/examples/dynamics/reaching_task/reaching_task_frequency_optimization.py on lines 51..57
          cocofest/examples/dynamics/reaching_task/reaching_task_intensity_optimization.py on lines 51..57

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

          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

          fes_muscle_models = [
              DingModelIntensityFrequencyWithFatigue(muscle_name="BIClong"),
              DingModelIntensityFrequencyWithFatigue(muscle_name="BICshort"),
              DingModelIntensityFrequencyWithFatigue(muscle_name="TRIlong"),
              DingModelIntensityFrequencyWithFatigue(muscle_name="TRIlat"),
          cocofest/examples/dynamics/reaching_task/reaching_task_frequency_optimization.py on lines 51..57
          cocofest/examples/dynamics/reaching_task/reaching_task_pulse_duration_optimization.py on lines 50..56

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

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

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

                                result += a[n] * np.cos(2.0 * np.pi * n * x / self.p) + b[n] * np.sin(2.0 * np.pi * n * x / self.p)
            Severity: Major
            Found in cocofest/fourier_approx.py and 1 other location - About 1 hr to fix
            cocofest/fourier_approx.py on lines 28..28

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

            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

            ocp = OcpFesMsk.prepare_ocp(
                biorbd_model_path="../msk_models/arm26.bioMod",
                bound_type="start",
                bound_data=[0, 90],
                fes_muscle_models=[
            cocofest/examples/dynamics/intensity_optimization_cycling_multi_muscle.py on lines 36..46

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

            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

            Severity
            Category
            Status
            Source
            Language