jardiacaj/finem_imperii

View on GitHub

Showing 323 of 336 total issues

Avoid too many return statements within this function.
Open

        return render(request, 'account/register.html')
Severity: Major
Found in account/views.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    if ( scope.enablePan === false ) return;
    Severity: Major
    Found in base/static/base/3rd/OrbitControls.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      if ( state !== STATE.TOUCH_PAN ) return; // is this needed?...
      Severity: Major
      Found in base/static/base/3rd/OrbitControls.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return redirect(character.activation_url)
        Severity: Major
        Found in character/views/creation.py - About 30 mins to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
          Severity: Minor
          Found in base/static/base/3rd/OrbitControls.js and 1 other location - About 30 mins to fix
          base/static/base/3rd/OrbitControls.js on lines 148..148

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 45.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          def capability_required_decorator(func):
              @inchar_required
              def inner(*args, **kwargs):
                  def fail_the_request(*args, **kwargs):
                      messages.error(args[0], "You cannot do that", "danger")
          Severity: Minor
          Found in organization/views/decorator.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

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

          def conquest_capability_view(request, capability_id):
              capability = get_object_or_404(
                  Capability, id=capability_id, type=Capability.CONQUEST)
              tile_to_conquer = get_object_or_404(
                  Tile,id=request.POST.get('tile_to_conquest_id'))
          Severity: Minor
          Found in organization/views/conquest.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

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

              def get_hunger_display(self):
                  return "satiated" if self.hunger <= 0 else \
                      "hungry" if self.hunger == 1 else \
                          "very hungry" if self.hunger in (2, 3) else \
                              "starving"
          Severity: Minor
          Found in world/models/npcs.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

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

          def diplomacy_capability_context(request, capability, context):
              if capability.applying_to.violence_monopoly:
                  context['states'] = []
                  for state in capability.applying_to.world.get_violence_monopolies():
                      if state == capability.applying_to:
          Severity: Minor
          Found in organization/views/capability.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

          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

          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

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

          def coordinate_neighbours(coord: Coordinates):
              result = []
              for dx in (-1, 0, 1):
                  for dz in (-1, 0, 1):
                      if not dx == dz == 0:
          Severity: Minor
          Found in battle/battle_tick.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

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

          def conquest_action(request, unit_id):
              unit = get_object_or_404(
                  WorldUnit,
                  id=unit_id,
                  owner_character=request.hero
          Severity: Minor
          Found in unit/views/actions.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

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

          def check_if_order_done(battle_unit_in_turn: BattleUnitInTurn):
              order = battle_unit_in_turn.battle_unit.get_order()
              if order:
                  if order.what == Order.MOVE:
                      if euclidean_distance(battle_unit_in_turn.coordinates(), order.target_location_coordinates()) == 0:
          Severity: Minor
          Found in battle/battle_tick.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

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

          def bureaucratic_work(request):
              if not request.hero.can_do_bureaucratic_work():
                  raise Http404("Can't do that")
          
              if request.method == "POST":
          Severity: Minor
          Found in character/views/actions.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

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

          def unit_attack_melee(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 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

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

          def create_unit(name, owner, location, soldiers, recruitment_type, unit_type):
              orders = Order.objects.create(what=Order.STAND)
          
              unit = WorldUnit.objects.create(
                  owner_character=owner,
          Severity: Minor
          Found in unit/creation.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

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

          def build_population_query_from_request(request, location):
              args = {}
              for arg_name, arg_type in flag_types.items():
                  arg = []
                  for arg_element in arg_type:
          Severity: Minor
          Found in unit/creation.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

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

          def unit_breaker(value, units):
              unit = units[0]
              unit_amount = value // unit.multiplier
              rest = value % unit.multiplier
              suffix = ''
          Severity: Minor
          Found in world/templatetags/extra_filters.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

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

              def ability_roll(self):
                  if self.wound_status == BattleSoldierInTurn.MEDIUM_WOUND:
                      if random.getrandbits(3) == 0:
                          self.able = False
                          self.save()
          Severity: Minor
          Found in world/models/npcs.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

          Severity
          Category
          Status
          Source
          Language