Showing 105 of 336 total issues
File models.py
has 333 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import namedtuple, defaultdict
import math
from django.urls import reverse
File organization.py
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.db import models, transaction
from django.urls import reverse
from django.utils.html import escape, format_html
from django.utils.safestring import mark_safe
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:
- Read upRead up
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
Function BaseRenderer
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
function BaseRenderer(initial_camera_x, initial_camera_y, initial_camera_z) {
var zis = this;
zis.picking_types = {};
Organization
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class Organization(models.Model, AdminURLMixin):
DEMOCRATIC = 'democratic' # decisions are voted among members
DISTRIBUTED = 'distributed' # decisions can be taken by each member
DECISION_TAKING_CHOICES = (
(DEMOCRATIC, DEMOCRATIC),
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
- Read upRead up
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 settlement_job_updates
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def settlement_job_updates(settlement: Settlement):
with perf_timer("NPC Job updates {}".format(settlement)):
settlement.get_residents().filter(able=False).update(workplace=None)
npcs_looking_for_a_job = settlement.get_residents().filter(
workplace=None,
- Read upRead up
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 optimistic_move_desire_resolving
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def optimistic_move_desire_resolving(battle: Battle):
while BattleContuberniumInTurn.objects.filter(desires_pos=True, battle_turn=battle.get_latest_turn()).exists():
bcuit = BattleContuberniumInTurn.objects.filter(desires_pos=True, battle_turn=battle.get_latest_turn())[0]
contubernia_desiring_position = battle.get_latest_turn().get_contubernia_desiring_position(bcuit.desired_coordinates())
desired_position_occupier = battle.get_latest_turn().get_contubernium_in_position(bcuit.desired_coordinates())
- Read upRead up
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_conquests
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def worldwide_conquests(world: World):
conquests_in_this_world = TileEvent.objects.filter(
type=TileEvent.CONQUEST,
active=True,
tile__world=world
- Read upRead up
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
WorldUnit
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class WorldUnit(models.Model, AdminURLMixin):
CONSCRIPTED = 'conscripted'
PROFESSIONAL = 'professional'
MERCENARY = 'mercenary'
RAISED = 'raised'
Function change_status
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def change_status(self, new_status):
if (
self.owner_character.profile != character.models.Character.COMMANDER and
self.owner_character.location != self.location
):
- Read upRead up
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_recipients_from_post_data
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def create_recipients_from_post_data(request, message):
raw_recipients = request.POST.getlist('recipient')
organization_count = 0
character_count = 0
- Read upRead up
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_unit_morale_display
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def get_unit_morale_display(self):
return (
"rebelling" if self.unit_morale <= 10 else
"very low" if self.unit_morale <= 25 else
"low" if self.unit_morale <= 50 else
- Read upRead up
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 update
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.update = function() {
var offset = new THREE.Vector3();
// so camera.up is the orbit axis
Function unit_movement
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def unit_movement(battle: Battle):
# first pass: desire positions / optimistic move
for battle_unit_in_turn in BattleUnitInTurn.objects.filter(battle_turn=battle.get_latest_turn()):
for battle_contubernium_in_turn in battle_unit_in_turn.battlecontuberniuminturn_set.all():
target_distance_function = get_target_distance_function(battle_contubernium_in_turn)
- Read upRead up
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 update
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function update () {
var position = scope.object.position;
offset.copy( position ).sub( scope.target );
Function post
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def post(self, request, *args, **kwargs):
action = request.POST.get('action')
bushels_to_transfer = int(request.POST.get('bushels'))
hours_needed = math.ceil(
bushels_to_transfer / request.hero.inventory_bushels_per_hour()
- Read upRead up
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_building_production
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def do_building_production(building: Building):
workers = building.worker
ideal_workers = min(building.max_ideal_workers(), workers.count())
surplus_workers = max(
0,
- Read upRead up
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 test_add_and_remove_contact
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_add_and_remove_contact(self):
target_character = Character.objects.get(id=3)
response = self.client.get(reverse('messaging:compose'))
self.assertContains(response, target_character.name, count=1)