Kev1CO/cocofest

View on GitHub

Showing 200 of 200 total issues

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

    def __init__(
        self,
        c3d_path: str | list[str] = None,
        calibration_matrix_path: str = None,
        for_identification: bool = False,
Severity: Minor
Found in data_process/force_from_c3d.py - About 3 days 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 a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring.
Open

    def _sanity_check_fes_models_inputs(
        biorbd_model_path,
        bound_type,
        bound_data,
        fes_muscle_models,
Severity: Minor
Found in cocofest/optimization/fes_ocp_dynamics.py - About 2 days 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 fes_ocp_dynamics.py has 830 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import numpy as np

from bioptim import (
    Axis,
    BoundsList,
Severity: Major
Found in cocofest/optimization/fes_ocp_dynamics.py - About 1 day to fix

    Function _set_bounds has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set_bounds(bio_models, fes_muscle_models, bound_type, bound_data, n_stim, initial_state):
            # ---- STATE BOUNDS REPRESENTATION ---- #
            #
            #                    |‾‾‾‾‾‾‾‾‾‾x_max_middle‾‾‾‾‾‾‾‾‾‾‾‾x_max_end‾
            #                    |          max_bounds              max_bounds
    Severity: Minor
    Found in cocofest/optimization/fes_ocp_dynamics.py - About 1 day 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 fes_ocp.py has 702 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import numpy as np
    
    from bioptim import (
        BoundsList,
        ConstraintList,
    Severity: Major
    Found in cocofest/optimization/fes_ocp.py - About 1 day to fix

      Function _build_parameters has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
      Open

          def _build_parameters(
              model,
              n_stim,
              time_min,
              time_max,
      Severity: Minor
      Found in cocofest/optimization/fes_ocp_dynamics.py - About 1 day 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 3 locations. Consider refactoring.
      Open

          if desired_mode == "single":
              with open(r"../../data/truncation_single.pkl", "rb") as f:
                  data = pickle.load(f)
                  single_parameter_list = data["parameter_list"]
                  single_force_total_results = data["force_total_results"]
      cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 25..37
      cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 39..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 132.

      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

          elif desired_mode == "triplet":
              with open(r"../../data/truncation_triplet.pkl", "rb") as f:
                  data = pickle.load(f)
                  triplet_parameter_list = data["parameter_list"]
                  triplet_force_total_results = data["force_total_results"]
      cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 11..23
      cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 25..37

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

      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

          elif desired_mode == "doublet":
              with open(r"../../data/truncation_doublet.pkl", "rb") as f:
                  data = pickle.load(f)
                  doublet_parameter_list = data["parameter_list"]
                  doublet_force_total_results = data["force_total_results"]
      cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 11..23
      cocofest/examples/sensitivity/truncation/summation_truncation_graph.py on lines 39..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 132.

      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 _set_objective has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

          def _set_objective(
              n_stim,
              n_shooting,
              force_fourier_coef,
              end_node_tracking,
      Severity: Minor
      Found in cocofest/optimization/fes_ocp_dynamics.py - About 6 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 ivp_fes.py has 401 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import numpy as np
      from bioptim import (
          ControlType,
          DynamicsList,
          InitialGuessList,
      Severity: Minor
      Found in cocofest/integration/ivp_fes.py - About 5 hrs to fix

        File ding2003_force_parameter_identification.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import time as time_package
        
        from bioptim import Solver, Objective, OdeSolver
        
        from ..models.fes_model import FesModel
        Severity: Minor
        Found in cocofest/identification/ding2003_force_parameter_identification.py - About 4 hrs to fix

          File ding2003.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

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

            ocp = OcpFesMsk.prepare_ocp(
                biorbd_model_path="../../msk_models/arm26_biceps_triceps.bioMod",
                bound_type="start_end",
                bound_data=[[0, 5], [0, 90]],
                fes_muscle_models=[
            cocofest/examples/dynamics/minimize_fatigue/pulse_duration_optimization_minimize_fatigue.py on lines 35..52

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

            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 dictionaries_check has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                def dictionaries_check(self):
                    if not isinstance(self.fes_parameters, dict):
                        raise ValueError("fes_parameters must be a dictionary")
            
                    if not isinstance(self.ivp_parameters, dict):
            Severity: Minor
            Found in cocofest/integration/ivp_fes.py - About 4 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

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

            ocp = OcpFesMsk.prepare_ocp(
                biorbd_model_path="../../msk_models/arm26_biceps_triceps.bioMod",
                bound_type="start_end",
                bound_data=[[0, 5], [0, 90]],
                fes_muscle_models=[
            cocofest/examples/dynamics/minimize_fatigue/pulse_intensity_optimization_minimize_fatigue.py on lines 37..54

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

            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_biceps_1dof.bioMod",
                bound_type="start_end",
                bound_data=[[5], [120]],
                fes_muscle_models=[DingModelPulseDurationFrequencyWithFatigue(muscle_name="BIClong")],
            cocofest/examples/getting_started/pulse_intensity_optimization_musculoskeletal_dynamic.py on lines 26..36

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

            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_biceps_1dof.bioMod",
                bound_type="start_end",
                bound_data=[[5], [120]],
                fes_muscle_models=[DingModelIntensityFrequencyWithFatigue(muscle_name="BIClong")],
            cocofest/examples/getting_started/pulse_duration_optimization_musculoskeletal_dynamic.py on lines 23..37

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

            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 __init__ has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(
                    self,
                    pickle_path: str | list[str] = None,
                    muscle_name: str | list[str] = None,
                    forearm_angle: int | float | list[int] | list[float] = None,
            Severity: Minor
            Found in data_process/force_from_sensor.py - About 4 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 _set_objective has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

                def _set_objective(
                    n_stim,
                    n_shooting,
                    force_fourier_coefficient,
                    end_node_tracking,
            Severity: Minor
            Found in cocofest/optimization/fes_ocp_nmpc_cyclic.py - About 4 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