jardiacaj/finem_imperii

View on GitHub
battle/battle_init.py

Summary

Maintainability
D
1 day
Test Coverage

Function output_formation has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def output_formation(self):
        widest_main_line_width = max([line.width for line in self.main_lines])
        full_size_of_line = (self.formation_object.element_size +
                             self.formation_object.spacing)
        flanks_x_offset = round(widest_main_line_width / 2) + \
Severity: Minor
Found in battle/battle_init.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

File battle_init.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import math

from django.db import transaction
from django.db.models.aggregates import Avg

Severity: Minor
Found in battle/battle_init.py - About 3 hrs to fix

    Function make_formation has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_formation(self):
            for line_index in range(5):
                for side_index in [0, 1, -1, 2, -2, 3, -3]:
                    units = self.get_battle_units_by_battle_settings(
                        line_index, side_index
    Severity: Minor
    Found in battle/battle_init.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 generate_in_turn_objects has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_in_turn_objects(battle):
        turn = BattleTurn.objects.create(
            battle=battle,
            num=0
        )
    Severity: Minor
    Found in battle/battle_init.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 initialize_from_conflict has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def initialize_from_conflict(battle, conflict, tile):
        for i, conflict_side in enumerate(conflict):
            battle_side = BattleSide.objects.create(
                battle=battle,
                z=i
    Severity: Minor
    Found in battle/battle_init.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 add_unit_to_battle_in_progress has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_unit_to_battle_in_progress(
            battle_organization: BattleOrganization,
            world_unit: WorldUnit
    ):
        battle = battle_organization.side.battle
    Severity: Minor
    Found in battle/battle_init.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 initialize_side_positioning has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def initialize_side_positioning(side: BattleSide):
        formation_settings = side.get_formation()
        if formation_settings.formation == BattleFormation.LINE:
            formation = LineFormation(side, formation_settings)
        else:
    Severity: Minor
    Found in battle/battle_init.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 joining_contubernium_position_generator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def joining_contubernium_position_generator():
        for z in range(30, 48):
            for x in range(20):
                for multiplier in (-1, 1):
                    yield Coordinates(x=x*multiplier, z=z)
    Severity: Minor
    Found in battle/battle_init.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