TabbycatDebate/tabbycat

View on GitHub

Showing 231 of 446 total issues

Function get_diversity_data_sets has a Cognitive Complexity of 32 (exceeds 8 allowed). Consider refactoring.
Open

def get_diversity_data_sets(t, for_public):

    all_regions = regions_ordered(t)

    region_values = [r['id'] for r in all_regions]
Severity: Minor
Found in tabbycat/standings/diversity.py - About 4 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_ballots_dicts has a Cognitive Complexity of 31 (exceeds 8 allowed). Consider refactoring.
Open

    def get_ballots_dicts(self):
        draw = self.round.debate_set_with_prefetches(iron=True)

        # Create the DebateIdentifiers for the ballots if needed
        create_identifiers(DebateIdentifier, draw)
Severity: Minor
Found in tabbycat/printing/views.py - About 4 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_speaker_columns has a Cognitive Complexity of 31 (exceeds 8 allowed). Consider refactoring.
Open

    def add_speaker_columns(self, speakers, categories=True):
        speaker_data = []
        for speaker in speakers:
            anonymous = getattr(speaker, 'anonymise', False) or speaker.anonymous
            if anonymous and not (self.admin and has_permission(self.user, Permission.VIEW_ANONYMOUS, self.tournament)):
Severity: Minor
Found in tabbycat/utils/tables.py - About 4 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 run_allocation has a Cognitive Complexity of 31 (exceeds 8 allowed). Consider refactoring.
Open

    def run_allocation(self):

        # Sort voting adjudicators in descending order by score
        voting = [a for a in self.adjudicators if a._weighted_score >= self.min_voting_score and not a.trainee]
        random.shuffle(voting)
Severity: Minor
Found in tabbycat/adjallocation/allocators/hungarian.py - About 4 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

DebateResultByAdjudicator has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class DebateResultByAdjudicator(BaseDebateResult):
    """Base class for voting ballots.

    Voting ballots have a DebateResult with one scoresheet per voting adjudicator.
    This also provides access to the TeamScoreByAdj table.
Severity: Minor
Found in tabbycat/results/result.py - About 4 hrs to fix

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

    import csv
    import json
    import logging
    import math
    
    
    Severity: Major
    Found in tabbycat/adjfeedback/views.py - About 4 hrs to fix

      Function generate has a Cognitive Complexity of 29 (exceeds 8 allowed). Consider refactoring.
      Open

          def generate(cls, to: 'QuerySet[Person]', debate: 'Debate') -> List[Tuple[EmailContextData, 'Person']]:
              emails = []
              tournament = debate.round.tournament
              results = DebateResult(debate.confirmed_ballot)
              round_name = _("%(tournament)s %(round)s @ %(room)s") % {'tournament': str(tournament),
      Severity: Minor
      Found in tabbycat/notifications/utils.py - About 3 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_debates has a Cognitive Complexity of 28 (exceeds 8 allowed). Consider refactoring.
      Open

          def import_debates(self):
              self.debates = {}
              self.debateteams = {}
              self.debateadjudicators = {}
      
      
      Severity: Minor
      Found in tabbycat/importer/archive.py - About 3 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_constrained_venues has a Cognitive Complexity of 28 (exceeds 8 allowed). Consider refactoring.
      Open

          def allocate_constrained_venues(self, debate_constraints):
              """Allocates venues for debates that have one or more constraints on
              them. `debate_constraints` should be
      
              For each debate, it finds the set of venues that meet all its
      Severity: Minor
      Found in tabbycat/venues/allocator.py - About 3 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_participants has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
      Open

          def add_participants(self):
              participants_tag = SubElement(self.root, 'participants')
      
              speaker_category_prefetch = Prefetch('speaker_set', queryset=Speaker.objects.all().prefetch_related('categories'))
              for team in self.t.team_set.all().prefetch_related(speaker_category_prefetch, 'break_categories'):
      Severity: Minor
      Found in tabbycat/importer/archive.py - About 3 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_two_team_generator has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
      Open

      def get_two_team_generator(draw_type, avoid_conflicts='australs', side_allocations=None, **kwargs):
      
          if draw_type == "first_elimination":
              return FirstEliminationDrawGenerator
          elif draw_type == "elimination":
      Severity: Minor
      Found in tabbycat/draw/generator/__init__.py - About 3 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 initial_data has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
      Open

          def initial_data(self):
              """Generates dictionary of initial form data."""
      
              initial = {}
      
      
      Severity: Minor
      Found in tabbycat/results/forms.py - About 3 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_debates has a Cognitive Complexity of 26 (exceeds 8 allowed). Consider refactoring.
      Open

          def add_debates(self, round_tag, motion, debate):
              debate_tag = SubElement(round_tag, 'debate', {
                  'id': DEBATE_PREFIX + str(debate.id),
              })
      
      
      Severity: Minor
      Found in tabbycat/importer/archive.py - About 3 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 26 (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 3 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 has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
      Open

          def clean(self):
              super().clean()
              section, first_pref = self.manager.parse_lookup(next(iter(self.cleaned_data.keys())))
              t = self.manager.instance
      
      
      Severity: Minor
      Found in tabbycat/options/forms.py - About 3 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_with_bubble_up_down has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
      Open

          def _intermediate_brackets_with_bubble_up_down(self, brackets):
              """Operates in-place.
              Requires Team.institution and Team.seen() to be defined."""
              self._intermediate_brackets(brackets)  # operates in-place
              # Check each of the intermediate brackets for conflicts.
      Severity: Minor
      Found in tabbycat/draw/generator/powerpair.py - About 3 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 __init__ has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
      Open

          def __init__(self, *args, **kwargs):
              super().__init__(*args, **kwargs)
      
              # Remove private fields in the public endpoint if needed
              if not is_staff(kwargs.get('context')):
      Severity: Minor
      Found in tabbycat/api/serializers.py - About 3 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 _make_question_field has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
      Open

          def _make_question_field(self, question):
              if question.answer_type == question.ANSWER_TYPE_BOOLEAN_SELECT:
                  field = BooleanSelectField()
              elif question.answer_type == question.ANSWER_TYPE_BOOLEAN_CHECKBOX:
                  field = forms.BooleanField(required=False)
      Severity: Minor
      Found in tabbycat/adjfeedback/forms.py - About 3 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

      BaseDebateResult has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class BaseDebateResult:
          """Base class for debate result.
      
          The base class implements management of debate teams, side allocations and
          team score saving.
      Severity: Minor
      Found in tabbycat/results/result.py - About 3 hrs to fix

        Round has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Round(models.Model):
        
            class DrawType(models.TextChoices):
                RANDOM = 'R', _('Random')
                MANUAL = 'M', _('Manual')
        Severity: Minor
        Found in tabbycat/tournaments/models.py - About 3 hrs to fix
          Severity
          Category
          Status
          Source
          Language