TabbycatDebate/tabbycat

View on GitHub

Showing 213 of 429 total issues

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

    def clean_scoresheet(self, cleaned_data):
        try:
            side_totals = {side: sum(cleaned_data[self._fieldname_score(side, pos)]
                           for pos in self.positions) for side in self.sides}
            totals = list(side_totals.values())
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 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 _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 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 add_debate_team_columns has a Cognitive Complexity of 22 (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 i, side in enumerate(self.tournament.sides, start=1):
                # 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

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

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

      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 _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_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 _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 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 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 _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 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 venue_conflicts_display has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
      Open

      def venue_conflicts_display(debates):
          """Returns a dict mapping elements (debates) in `debates` to a list of
          strings of explaining unfulfilled venue constraints for participants that
          debate. A venue constraint (or more precisely, a set of venue constraints
          relating to a single participant) is "unfulfilled" if the relevant
      Severity: Minor
      Found in tabbycat/venues/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

      Function clean_scores_raw has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
      Open

          def clean_scores_raw(self):
              lines = self.cleaned_data['scores_raw'].split('\n')
              errors = []
              records = []
      
      
      Severity: Minor
      Found in tabbycat/adjfeedback/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 allocate_debate_adjs has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
      Open

          def allocate_debate_adjs(self, event):
              round = Round.objects.get(pk=event['extra']['round_id'])
              self._apply_allocation_settings(round, event['extra']['settings'])
      
              if round.draw_status == round.Status.RELEASED:
      Severity: Minor
      Found in tabbycat/adjallocation/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

      Function add_adjudicator_columns has a Cognitive Complexity of 18 (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 1 hr 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