Showing 52 of 61 total issues
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, env: gym.Env, expert_trajs: List[Dict[str, list]],
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Function get_maps
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_maps(ascii_map: List[str]) -> (np.ndarray, np.ndarray):
"""Transform an ASCII-ascii_map into matrices of walls and rewards
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 train
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def train(self, no_episodes: int):
""" Train the agent
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 unwrap_env
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def unwrap_env(env: gym.Env,
until_class: Union[None, gym.Env] = None) -> gym.Env:
"""Unwrap wrapped env until we get an instance that is a until_class.
If until_class is None, env will be unwrapped until the lowest layer.
- 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 domain
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def domain(self) -> Union[State, StateAction, StateActionState]:
"""Return the entire domain of the reward function.
Returns
-------
- 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 make_env
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def make_env(env_id: str):
"""Make a basic gym environment, without any special wrappers.
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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, map_id: int = 0):
"""
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
Method "__init__" has 8 parameters, which is greater than the 7 authorized. Open
def __init__(self, env_id: str, expert_trajs_path: str,
irl_alg_factory: Callable[[gym.Env, List[Dict[str, list]]],
BaseIRLAlgorithm],
metrics: List[BaseMetric], rl_config: dict, irl_config: dict,
run_config: dict):
- Read upRead up
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...
Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed. Open
def collect_trajs(env: gym.Env,
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed. Open
def train(self, no_irl_iterations: int,
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed. Open
def occupancy_measure(self,
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.