Showing 231 of 446 total issues
Function get_teams
has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring. Open
def get_teams(self) -> Tuple[List['Team'], List['Team']]:
"""Get teams in ranked order."""
teams = add(*super().get_teams())
teams = self.round.tournament.team_set.filter(id__in=[t.id for t in teams])
- 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 _intermediate_brackets_1
has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring. Open
def _intermediate_brackets_1(cls, brackets):
"""Operates in-place.
This implements the first intermediate brackets method, where there is at most
one intermediate bracket between brackets, but may have pullups from multiple
brackets.
- 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 load_scoresheets
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def load_scoresheets(self):
super().load_scoresheets()
speakerscorebyadjs = self.ballotsub.speakerscorebyadj_set.filter(
debate_adjudicator__in=self.debateadjs_query,
- 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_score_fields
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def create_score_fields(self):
"""Adds the speaker score fields:
- <side>_score_a#_s#, one for each score
"""
for side, pos in product(self.sides, self.positions):
- 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 postprocess_result
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def postprocess_result(self):
if self.ballotsub.single_adj and self.tournament.pref('disable_ballot_confirms'):
merged_bs = BallotSubmission(
debate=self.debate,
submitter=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 load_scoresheets
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def load_scoresheets(self):
super().load_scoresheets()
speakerscores = self.ballotsub.speakerscore_set.filter(
debate_team__side__in=self.sides,
- 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 _interpret_metrics
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def _interpret_metrics(self, metrics, extra_metrics):
"""Given a list of metric keys, sets:
- `self.precedence` to a copy of `metrics` with repeated metric annotators numbered
- `self.metric_annotators` to the appropriate metric annotators
For example:
- 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_tables
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def get_tables(self) -> List[TabbycatTableBuilder]:
tables = []
# notifications.sentmessage_set.first().emailstatus_set.first().latest_statuses will be a list
notifications = self.tournament.bulknotification_set.select_related(
- 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 prioritise_debates
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def prioritise_debates(self, event):
# TODO: Debates and panels should really be unified in a single function
round = Round.objects.get(pk=event['extra']['round_id'])
debates = round.debate_set_with_prefetches(teams=True, adjudicators=False,
speakers=False, venues=False)
- 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 prioritise_panels
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def prioritise_panels(self, event):
rd = Round.objects.get(pk=event['extra']['round_id'])
panels = rd.preformedpanel_set.all()
priority_method = event['extra']['settings']['type']
- 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 __init__
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def __init__(self, container, chair=None, panellists=None, trainees=None, from_db=False):
"""The `container` is a model instance that relates to adjudicators via
a RelatedManager. It's easiest to think of this as a "panel", though the
typical use case is actually a debate. The model instance's model class
must define a property `related_adjudicator_set`, which must be the
- 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_context_data
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_context_data(self, **kwargs):
t = self.tournament
adjudicators = self.get_adjudicators()
weight = t.current_round.feedback_weight
scores = [a.weighted_score(weight) for a in adjudicators]
Function handle_tournament
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def handle_tournament(self, tournament, **options):
for team in tournament.team_set.all():
if team.reference.startswith(team.institution.code + " "):
new_reference = team.reference[len(team.institution.code):].strip()
self.stdout.write("{verb} team {!r} from {} to {!r}".format(
- 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 populate_objects
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def populate_objects(self, prefill=True):
self.object = self.get_object() # must be populated before self.error_page() called
if self.round.draw_status != Round.Status.RELEASED:
return self.error_page(_("The draw for this round hasn't been released yet."))
- 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 merge_speaker_result
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def merge_speaker_result(self, result: BaseDebateResult) -> list[ResultError]:
errors = self.merge_speaker_order(result)
for side, pos in product(self.sides, self.positions):
for criterion in self.criteria:
if self.get_criterion_score(side, pos, criterion) is 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 import_speakers
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def import_speakers(self, f, auto_create_teams=True):
"""Imports speakers, also creating teams as needed (unless
'auto_create_teams' is False). Institutions are not created as needed;
if an institution doesn't exist, an error is raised.
"""
- 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_url_args
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def get_url_args(parser, token):
"""Helper function, returns the arguments necessary to construct a URL node.
This code is copied directly from `url` in django/template/defaulttags.py,
except that instead of constructing a URL node with the identified
parameters, it simply returns the parameters in a tuple.
- 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_feedbacks
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def get_feedbacks(self):
feedbacks = self.get_feedback_queryset()
populate_debate_adjudicators(feedbacks)
populate_wins_for_debateteams([f.source_team for f in feedbacks if f.source_team is not 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 has_permission
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def has_permission(user: 'settings.AUTH_USER_MODEL', permission: permission_type, tournament: 'Tournament') -> bool:
if user.is_anonymous:
return False
if user.is_superuser:
return True
- 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 add_draw_conflicts_columns
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
def add_draw_conflicts_columns(self, debates, venue_conflicts, adjudicator_conflicts):
conflicts_by_debate = []
for debate in debates:
# conflicts is a list of (level, message) tuples
- 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"