jardiacaj/finem_imperii

View on GitHub

Showing 105 of 336 total issues

Function create_unit has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def create_unit(name, owner, location, soldiers, recruitment_type, unit_type):
Severity: Minor
Found in unit/creation.py - About 45 mins to fix

    Function do_state_taxes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def do_state_taxes(state: Organization):
        if not state.character_members.exists():
            return
    
        settlement_input = []
    Severity: Minor
    Found in turn/taxes.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 safe_move has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def safe_move(battle_contubernium_in_turn: BattleContuberniumInTurn, target_distance_function):
        turn = battle_contubernium_in_turn.battle_turn
    
        def tile_availability_test(coords: Coordinates):
            return True if turn.get_contubernium_in_position(coords) is None else False
    Severity: Minor
    Found in battle/battle_tick.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

    Avoid deeply nested control flow statements.
    Open

                        for soldier in contubernium.battlesoldier_set.all():
                            try:
                                bsit = BattleSoldierInTurn.objects.get(
                                    battle_turn=prev_turn,
                                    battle_soldier=soldier
    Severity: Major
    Found in battle/battle_tick.py - About 45 mins to fix

      Function heir_capability_view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def heir_capability_view(request, capability_id):
          capability = get_object_or_404(
              Capability, id=capability_id, type=Capability.HEIR)
      
          first_heir_id = request.POST.get('first_heir')
      Severity: Minor
      Found in organization/views/heir.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 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 create_message has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def create_message(
      Severity: Minor
      Found in messaging/shortcuts.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if desirer.coordinates() == desired_position_occupier.desired_coordinates():
                                grant_position_swap(desirer, desired_position_occupier)
                                continue
                        # TODO: try to move blocking contubernium before giving up
                        contubernia_desiring_position.update(desires_pos=False)
        Severity: Major
        Found in battle/battle_tick.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for contubernium_in_turn in contubernium.battlecontuberniuminturn_set.all():
                                  contubernia[contubernium.id]['in_turn'][contubernium_in_turn.battle_turn.num] = {
                                      'x_pos': contubernium_in_turn.x_pos,
                                      'z_pos': contubernium_in_turn.z_pos,
                                      'ammo_remaining': contubernium_in_turn.ammo_remaining,
          Severity: Major
          Found in battle/battle_renderer.py - About 45 mins to fix

            Function unit_attack_ranged has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def unit_attack_ranged(contubernium: BattleContuberniumInTurn,
                                   target_contubernium: BattleContuberniumInTurn):
                for soldier in contubernium.battlesoldierinturn_set.all():
                    target_soldier = random.choice(
                        target_contubernium.battlesoldierinturn_set.all()[:]
            Severity: Minor
            Found in battle/battle_tick.py - About 35 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 unit_attack has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def unit_attack(battle: Battle):
                contubernia = list(BattleContuberniumInTurn.objects.filter(
                    battle_turn=battle.get_latest_turn()
                ))
                random.shuffle(contubernia)
            Severity: Minor
            Found in battle/battle_tick.py - About 35 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 resolve has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def resolve(self):
                    max_votes = 0
                    winners = []
                    for candidacy in self.open_candidacies().all():
                        votes = candidacy.positionelectionvote_set.count()
            Severity: Minor
            Found in organization/models/election.py - About 35 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 worldwide_unit_maintenance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def worldwide_unit_maintenance(world: World):
                for unit in world.worldunit_set.all():
                    do_unit_status_update(unit)
                    do_unit_debt_increase(unit)
                    if unit.auto_pay and unit.owner_character:
            Severity: Minor
            Found in turn/unit.py - About 35 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 get_bootstrap_icon has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_bootstrap_icon(self):
                    template = '<span style="color: #{color}" ' \
                               'class="glyphicon glyphicon-{icon}" ' \
                               'aria-hidden="true"></span>'
                    if self.violence_monopoly and not self.barbaric:
            Severity: Minor
            Found in organization/models/organization.py - About 35 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 build_population_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def build_population_query(location, **kwargs):
                candidates = all_recruitable_soldiers_in_settlement(location)
            
                for arg_name, arg_values in kwargs.items():
                    qs = []
            Severity: Minor
            Found in unit/creation.py - About 35 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 check_end has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def check_end(battle: Battle):
                for side in battle.battleside_set.all():
                    if not BattleSoldierInTurn.objects.filter(
                        battle_turn=battle.get_latest_turn(),
                        battle_contubernium_in_turn__battle_contubernium__battle_unit__battle_side=side,
            Severity: Minor
            Found in battle/battle_tick.py - About 35 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

            Avoid too many return statements within this function.
            Open

                        return result
            Severity: Major
            Found in battle/battle_tick.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return capability_success(capability, request)
              Severity: Major
              Found in organization/views/diplomacy.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return result
                Severity: Major
                Found in battle/battle_tick.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return redirect('account:login')
                  Severity: Major
                  Found in account/views.py - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language