jardiacaj/finem_imperii

View on GitHub

Showing 105 of 336 total issues

Function add_political_markings has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    zis.add_political_markings = function () {
        for (var region_id in zis.regions)  {
            if (Object.prototype.hasOwnProperty.call(zis.regions, region_id)) {
                var region = world_data.regions[region_id];
                var organization = zis.organizations[region.controlled_by];
Severity: Minor
Found in world/static/world/world_renderer.js - About 1 hr to fix

    Function test_message_favourite_unfavourite has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def test_message_favourite_unfavourite(self):
            message_body = 'Nice to meet you, foobar.'
            response = self.client.post(
                reverse('messaging:compose'),
                data={
    Severity: Minor
    Found in messaging/tests.py - About 1 hr to fix

      Function post has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def post(self, request, capability_id, target_organization_id):
              capability = get_object_or_404(
                  Capability, id=capability_id, type=Capability.DIPLOMACY
              )
              target_organization = get_object_or_404(
      Severity: Minor
      Found in organization/views/diplomacy.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 do_settlement_barbarian_generation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def do_settlement_barbarian_generation(settlement: Settlement):
          with perf_timer("Barbarian generation at {}".format(settlement)):
              if settlement.population < 40:
                  return
      
      
      Severity: Minor
      Found in turn/barbarians.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 remove_member has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_member(self, member):
              if member not in self.character_members.all():
                  raise Exception("{} is not a member of {}".format(member, self))
              self.character_members.remove(
                  member
      Severity: Minor
      Found in organization/models/organization.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 login_view has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def login_view(request):
          if request.POST:
              username = request.POST.get('username')
              password = request.POST.get('password')
              user = authenticate(username=username, password=password)
      Severity: Minor
      Found in account/views.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 generate_organization_materials has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          zis.generate_organization_materials = function () {
              var loader = new THREE.TextureLoader();
              var unit_type_index;
      
              var unit_types = ['infantry', 'archers'];
      Severity: Minor
      Found in battle/static/battle/battle_renderer.js - About 1 hr to fix

        Function test_mark_as_read has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def test_mark_as_read(self):
                message_body = 'Nice to meet you, foobar.'
                response = self.client.post(
                    reverse('messaging:compose'),
                    data={
        Severity: Minor
        Found in messaging/tests.py - About 1 hr to fix

          Function animated_update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              zis.animated_update = function () {
                  for (var contubernium_id in zis.contubernia) {
                      if (Object.prototype.hasOwnProperty.call(
                              zis.contubernia, contubernium_id)) {
                          var contubernium = zis.contubernia[contubernium_id];
          Severity: Minor
          Found in battle/static/battle/battle_renderer.js - About 1 hr to fix

            Function get_order has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_order(self):
                    if self.world_unit.owner_character:
                        return self.world_unit.default_battle_orders
                    else:
                        strength_proportion = self.battle_side.get_proportional_strength()
            Severity: Minor
            Found in battle/models.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 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 post has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def post(self, request, *args, **kwargs):
                    if not can_create_character(request.user):
                        raise Http404()
            
                    try:
            Severity: Minor
            Found in character/views/creation.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 do_settlement_food_consumption has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def do_settlement_food_consumption(settlement: Settlement):
                mouths = settlement.population
                granary = settlement.get_default_granary()
                bushels_to_consume = min(
                    mouths,
            Severity: Minor
            Found in turn/demography.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 register_view has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def register_view(request):
                if request.user.is_authenticated:
                    return redirect('account:home')
                if request.POST:
                    username = request.POST.get('username')
            Severity: Minor
            Found in account/views.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 worldwide_elections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def worldwide_elections(world: World):
                for election in PositionElection.objects.filter(
                    position__world=world,
                    turn=world.current_turn
                ):
            Severity: Minor
            Found in turn/elections.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 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

            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

              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
                Severity
                Category
                Status
                Source
                Language