TabbycatDebate/tabbycat

View on GitHub

Showing 231 of 446 total issues

File views.py has 639 lines of code (exceeds 600 allowed). Consider refactoring.
Open

import datetime
import logging
import unicodedata
from itertools import product
from zoneinfo import ZoneInfo
Severity: Major
Found in tabbycat/draw/views.py - About 2 hrs to fix

    Function broadcast_checkin has a Cognitive Complexity of 24 (exceeds 8 allowed). Consider refactoring.
    Open

        def broadcast_checkin(self, event):
            content = event['content']
            barcode_ids = [b for b in content['barcodes'] if b is not None]
            return_content = {'created': content['status'], 'checkins': [],
                              'component_id': content['component_id']}
    Severity: Minor
    Found in tabbycat/checkins/consumers.py - About 2 hrs 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

    ConsensusDebateResult has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ConsensusDebateResult(BaseDebateResult):
        """Consensus debate result without scores"""
    
        def init_blank_buffer(self):
            super().init_blank_buffer()
    Severity: Minor
    Found in tabbycat/results/result.py - About 2 hrs to fix

      Function _collate_prelim_motion_annotations has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
      Open

          def _collate_prelim_motion_annotations(self):
              """Collect annotations (which will be attributes) and convert them to
              dictionaries to allow for easy iteration in the template."""
      
              for motion in self.prelim_motions_dict.values():
      Severity: Minor
      Found in tabbycat/motions/statistics.py - About 2 hrs 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 handle_tournament has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
      Open

          def handle_tournament(self, tournament, **options):
              for slug in options["slug"]:
                  try:
                      break_category = tournament.breakcategory_set.get(slug=slug)
                  except ObjectDoesNotExist:
      Severity: Minor
      Found in tabbycat/breakqual/management/commands/fixbreakeligibility.py - About 2 hrs 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 expected_feedback_targets has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
      Open

      def expected_feedback_targets(debateadj, feedback_paths=None, debate=None):
          """Returns a list of adjudicators and positions (adj, pos), each being
          someone that the given DebateAdjudicator object is expected to give feedback
          on. If the debate adjudicator's position and the tournament preferences
          dictate that the source adjudicator should not submit feedback on anyone for
      Severity: Minor
      Found in tabbycat/adjfeedback/utils.py - About 2 hrs 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

      Tournament has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Tournament(models.Model):
          name = models.CharField(max_length=100,
              verbose_name=_("name"),
              help_text=_("The full name, e.g. \"Australasian Intervarsity Debating Championships 2016\""))
          short_name = models.CharField(max_length=25, blank=True, default="",
      Severity: Minor
      Found in tabbycat/tournaments/models.py - About 2 hrs to fix

        Function get_tournaments has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
        Open

            def get_tournaments(self, options):
                """Returns a list of tournaments implied by command-line arguments.
                Implementation note: For caching purposes, this stores the result in
                the "__tournaments__" key of the options dict."""
        
        
        Severity: Minor
        Found in tabbycat/utils/management/base.py - About 2 hrs 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_debate_standing_columns has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
        Open

            def _add_debate_standing_columns(self, debates, standings, itermethod, infomethod, formattext, formatsort, limit=None):
                standings_by_debate = [standings.get_standings(d.teams) if not d.is_bye else None for d in debates]
                sides = self.get_sides(debates)
                cells = []
        
        
        Severity: Minor
        Found in tabbycat/draw/tables.py - About 2 hrs 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 _team_cell has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
        Open

            def _team_cell(self, team, show_emoji=False, subtext=None, highlight=False):
                cell = {
                    'text': self._team_short_name(team),
                    'emoji': escape(team.emoji) if team.emoji and show_emoji and self.tournament.pref('show_emoji') else None,
                    'sort': self._team_short_name(team),
        Severity: Minor
        Found in tabbycat/utils/tables.py - About 2 hrs 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 clean_scoresheet has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
        Open

            def clean_scoresheet(self, cleaned_data):
                for adj in self.adjudicators:
                    try:
                        if self.criteria:
                            side_totals = {side: sum(float(cleaned_data[self._fieldname_criterion_score(adj, side, pos, criterion)] or 0) * criterion.weight
        Severity: Minor
        Found in tabbycat/results/forms.py - About 2 hrs 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 _result_cell_bp has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
        Open

            def _result_cell_bp(self, ts, compress=False, show_score=False, show_ballots=False):
                if not hasattr(ts, 'debate_team'):
                    return {'text': self.BLANK_TEXT}
        
                other_teams = {dt.side: self._team_short_name(dt.team) for dt in ts.debate_team.debate.debateteam_set.all()}
        Severity: Minor
        Found in tabbycat/utils/tables.py - About 2 hrs 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_standard_table has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
        Open

            def get_standard_table(self):
                r = self.round
        
                if r.is_break_round:
                    sort_key = "room-rank"
        Severity: Minor
        Found in tabbycat/draw/views.py - About 2 hrs 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 import_teams has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
        Open

            def import_teams(self, f):
                speaker_fields = ['name', 'email', 'category', 'gender']
        
                team_interpreter_part = make_interpreter(
                    tournament=self.tournament,
        Severity: Minor
        Found in tabbycat/importer/importers/boots.py - About 2 hrs 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 _intermediate_brackets_2 has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
        Open

            def _intermediate_brackets_2(cls, brackets):
                """Operates in-place.
                This implements the second intermediate brackets method, where all debates
                in the same intermediate bracket have the same number of wins, but there
                might be multiple intermediate brackets between brackets.
        Severity: Minor
        Found in tabbycat/draw/generator/powerpair.py - About 2 hrs 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 _one_up_one_down has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
        Open

            def _one_up_one_down(self, pairings):
                """We pass the pairings to one_up_one_down.py, then infer annotations
                based on the result."""
        
                for bracket in pairings.values():
        Severity: Minor
        Found in tabbycat/draw/generator/powerpair.py - About 2 hrs 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 handle_round has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
        Open

            def handle_round(self, round, **options):
                if (not options["preformed"] and not options["force"] and
                        round.draw_status != Round.Status.CONFIRMED):
                    raise CommandError("Draw status isn't confirmed (it's {}), use "
                        "--force to run anyway".format(round.get_draw_status_display().lower()))
        Severity: Minor
        Found in tabbycat/adjallocation/management/commands/allocateadjudicators.py - About 2 hrs 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 avoid_conflicts has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
        Open

            def avoid_conflicts(self, pairings):
                # Don't swap sides! The child class RandomDrawWithSideConstraints assumes
                # that in this algorithm, affs will stay affs and negs will stay negs.
                if not (self.options["avoid_history"] or self.options["avoid_institution"]):
                    return
        Severity: Minor
        Found in tabbycat/draw/generator/random.py - About 2 hrs 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_debate_team_columns has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
        Open

            def add_debate_team_columns(self, debates, highlight=[]):
                all_sides_confirmed = all(debate.sides_confirmed for debate in debates)  # should already be fetched
        
                for side in range(self.get_sides(debates)):
                    # For BP team names are often longer than the full position label
        Severity: Minor
        Found in tabbycat/draw/tables.py - About 2 hrs 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_adjudicator_columns has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
        Open

            def add_adjudicator_columns(self, adjudicators, show_institutions=True,
                    show_metadata=True, subtext=None):
        
                adj_data = []
                for adj in adjudicators:
        Severity: Minor
        Found in tabbycat/utils/tables.py - About 2 hrs 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