Function try_parse_policy_definition
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def try_parse_policy_definition(meta: Optional[dict[str, Any]]) -> Optional[PolicyDefinition]:
if not meta:
return None
weights = {}
for key, value in meta.items():
- 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 _override_policy_def
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _override_policy_def(
policy_def: PolicyDefinition,
parent: Optional[PolicyDefinition],
*,
is_ephemeral: bool,
- 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_balance_policy
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_balance_policy(self, balance: Balance) -> Optional[Policy[WeightedOwnership]]:
has_explicit_policy = False
balance_policy_def = try_parse_policy_definition(balance.meta)
if balance_policy_def:
balance_policy_def = self._resolve_parent(balance_policy_def)
- 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 add_policy
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_policy(self, name: str, policy_def: PolicyDefinition) -> None:
if policy_def.parent and policy_def.parent not in self._named_policies:
raise error_lib.PluginException(
f'Reference to unknown share policy {policy_def.parent!r}')
if policy_def.enforced and not policy_def.ownership:
- 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"