jardiacaj/finem_imperii

View on GitHub
turn/battle.py

Summary

Maintainability
C
1 day
Test Coverage

Function battle_joins has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

def battle_joins(battle: Battle):
    for candidate_unit in battle_ready_units_in_tile(battle.tile):
        candidate_vm = candidate_unit.get_violence_monopoly()
        try:
            battle_org = BattleOrganization.objects.get(
Severity: Minor
Found in turn/battle.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 add_allies has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def add_allies(conflict, tile):
    for i, conflict_side in enumerate(conflict):
        other_conflict_side = conflict[0 if i == 1 else 1]
        for candidate in organizations_with_battle_ready_units(tile):
            if candidate in conflict_side or candidate in other_conflict_side:
Severity: Minor
Found in turn/battle.py - About 3 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 get_largest_conflict_in_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_largest_conflict_in_list(conflicts, tile):
    result = None
    max_soldiers = 0
    for conflict in conflicts:
        soldiers = 0
Severity: Minor
Found in turn/battle.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

Function opponents_in_organization_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def opponents_in_organization_list(organizations, tile):
    potential_conflicts = []

    input_list = list(organizations)
    while len(input_list):
Severity: Minor
Found in turn/battle.py - About 25 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