SEIAROTg/autobean

View on GitHub
autobean/share/policy_lib.py

Summary

Maintainability
B
5 hrs
Test Coverage
A
99%

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():
Severity: Minor
Found in autobean/share/policy_lib.py - About 2 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 _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,
Severity: Minor
Found in autobean/share/policy_lib.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 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)
Severity: Minor
Found in autobean/share/policy_lib.py - About 55 mins 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 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:
Severity: Minor
Found in autobean/share/policy_lib.py - About 45 mins 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

There are no issues that match your filters.

Category
Status