Showing 631 of 631 total issues
File variational_optimal_control_program.py
has 471 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
Optimal control program with the variational integrator for the dynamics.
"""
import numpy as np
Function plot_results
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
def plot_results(
sol_socp,
states,
controls,
time,
- Read upRead up
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 non_linear_program.py
has 450 lines of code (exceeds 250 allowed). Consider refactoring. Open
from typing import Callable, Any
import casadi
from casadi import SX, MX, vertcat
File mapping.py
has 448 lines of code (exceeds 250 allowed). Consider refactoring. Open
import numpy as np
from casadi import MX, SX, DM
from .options import OptionDict, OptionGeneric
from .enums import Node
File optimization_vector.py
has 442 lines of code (exceeds 250 allowed). Consider refactoring. Open
import numpy as np
from casadi import vertcat, DM, SX, MX
from ..misc.enums import ControlType, InterpolationType
ACADOS
has 47 functions (exceeds 20 allowed). Consider refactoring. Open
class ACADOS(GenericSolver):
"""
Class for Solver Options of ACADOS
Methods
Similar blocks of code found in 2 locations. Consider refactoring. Open
for i in range(2):
axs[1, i].step(stepwise_time, stepwise_controls["tau"][i, :], label="Stepwise tau", where="post")
axs[1, i].set_xlabel("Time [s]")
axs[1, i].grid(True)
axs[1, i].legend()
- Read upRead up
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 103.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for i in range(2):
axs[0, i].step(decision_time, decision_controls["tau"][i, :], label="Decision tau", where="post")
axs[0, i].set_xlabel("Time [s]")
axs[0, i].grid(True)
axs[0, i].legend()
- Read upRead up
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 103.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function define_parameters_phase_time
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def define_parameters_phase_time(
ocp: OptimalControlProgram,
penalty_functions: ObjectiveList | ConstraintList,
_has_penalty: list = None,
) -> list:
- Read upRead up
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 FatigueBounds
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def FatigueBounds(fatigue: FatigueList, variable_type=VariableType.STATES, fix_first_frame=False):
"""
Parameters
----------
fatigue: FatigueList
- Read upRead up
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 _dispatch_state_bounds
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def _dispatch_state_bounds(nlp, states, states_bounds, states_scaling, n_steps_callback):
states.node_index = 0
repeat = n_steps_callback(0)
for key in states.keys():
- Read upRead up
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 _dispatch_state_initial_guess
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def _dispatch_state_initial_guess(nlp, states, states_init, states_scaling, n_steps_callback):
states.node_index = 0
repeat = n_steps_callback(0)
for key in states.keys():
- Read upRead up
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 __init__
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def __init__(
self,
nb_elements: int = None,
independent_indices: tuple[int, ...] = None,
dependencies: tuple[Dependency, ...] = None,
- Read upRead up
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 holonomic_biorbd_model.py
has 415 lines of code (exceeds 250 allowed). Consider refactoring. Open
from typing import Callable
import biorbd_casadi as biorbd
from biorbd_casadi import (
GeneralizedCoordinates,
Function _check_arguments_and_build_nlp
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def _check_arguments_and_build_nlp(
self,
dynamics,
objective_functions,
constraints,
- Read upRead up
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_penalty_function
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def _set_penalty_function(self, controllers: list[PenaltyController], fcn: MX | SX):
"""
Finalize the preparation of the penalty (setting function and weighted_function)
Parameters
- Read upRead up
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 _auto_initialize
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def _auto_initialize(self, x_init, u_init, parameter_init, a_init):
def replace_initial_guess(key, n_var, var_init, a_init, i_phase):
if n_var != 0:
if key in a_init:
a_init[key] = InitialGuess(var_init, interpolation=InterpolationType.EACH_FRAME, phase=i_phase)
- Read upRead up
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 __init__
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def __init__(
self,
bio_model: VariationalBioModel,
n_shooting: int,
final_time: float,
- Read upRead up
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 _compute_y_from_plot_func
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def _compute_y_from_plot_func(
self, custom_plot: CustomPlot, phase_idx, time_stepwise, dt, x_decision, x_stepwise, u, p, a, d
) -> list[np.ndarray | list]:
"""
Compute the y data from the plot function
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _get_u
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def _get_u(self, ocp, p_idx, n_idx, sn_idx):
nlp = ocp.nlp[p_idx]
controls = nlp.controls
controls.node_index = n_idx
- Read upRead up
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"