Showing 231 of 446 total issues
Avoid deeply nested control flow statements. Open
if int(side.find('ballot').get('rank')) == 1:
dr.add_winner(side_code)
else:
Function add_ballot_check_in_columns
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
def add_ballot_check_in_columns(self, debates, key):
status_header = {
'key': key,
'tooltip': _("Whether this debate's ballot has been checked in"),
- 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 DrawGenerator
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def DrawGenerator(teams_in_debate, draw_type, teams, results=None, rrseq=None, **kwargs): # noqa: N802 (factory function)
Avoid deeply nested control flow statements. Open
if field == 'speaker':
message += " (original score {})".format(ss.score)
self.stdout.write(message)
Function _add_constraint_message
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _add_constraint_message(debate, instance, venue, success_message, failure_message, message_args):
Function add_feedback
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_feedback(debate, submitter_type, user, probability=1.0, discarded=False, confirmed=False):
Avoid deeply nested control flow statements. Open
if cat.public:
category_strs.append(escape(cat.name))
elif self.admin:
category_strs.append("<em>" + escape(cat.name) + "</em>")
categories_data.append(", ".join(category_strs))
Function validate
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
def validate(self, data):
# Convert answer to correct type
model = AdjudicatorFeedbackQuestion.ANSWER_TYPE_CLASSES[data['question'].answer_type]
if type(data['answer']) != model.ANSWER_TYPE:
raise serializers.ValidationError({'answer': 'The answer must be of type %s' % model.ANSWER_TYPE.__name__})
- 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 11 (exceeds 8 allowed). Consider refactoring. Open
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not is_staff(kwargs.get('context')):
t = kwargs['context']['tournament']
with_permission = partial(has_permission, user=kwargs['context']['request'].user, tournament=t)
- 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
Consider simplifying this complex logical expression. Open
if feedback_paths == 'no-adjs':
targets = []
elif feedback_paths == 'all-adjs' or debateadj.type == DebateAdjudicator.TYPE_CHAIR:
targets = [(adj, pos) for adj, pos in adjudicators.with_positions() if adj.id != debateadj.adjudicator_id]
elif feedback_paths == 'with-p-on-p' and debateadj.type == DebateAdjudicator.TYPE_PANEL:
Function add_team_ballots
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_team_ballots(self, side_tag, result, adj, scoresheet, side):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, ballotsub, tabroom, password=False, *args, **kwargs):
Function set_criterion_score
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_criterion_score(self, adj, side, pos, criterion, score):
Function build
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build(self, draw, teams, side_histories_before, side_histories_now, standings):
Function receive_debate_change
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def receive_debate_change(self, content, key, content_name, field_name, serializer):
Function build
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build(self, debates, teams, side_histories_before, side_histories_now, standings):
Function add_debate_adjudicators_column
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_debate_adjudicators_column(self, debates, title="Adjudicators",
Function liveness
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def liveness(self, team, teams_count, prelims, current_round):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, teams, bracket, room_rank, flags=[], team_flags={}):
Function construct_info
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def construct_info(self, venue, source, source_p, target, target_p):