TabbycatDebate/tabbycat

View on GitHub

Showing 174 of 2,008 total issues

File emoji.py has 1527 lines of code (exceeds 600 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
import random
import logging

logger = logging.getLogger(__name__)
Severity: Major
Found in tabbycat/participants/emoji.py - About 3 days to fix

    Function _import has a Cognitive Complexity of 90 (exceeds 8 allowed). Consider refactoring.
    Open

        def _import(self, csvfile, model, interpreter=make_interpreter(), expect_unique=None):
            """Parses the object given in f, using the callable interpreter to parse
            each line, and passing the arguments to the given model's constructor.
            `csvfile` can be any object that is supported by csv.DictReader(), which
            includes file objects and lists of strings.
    Severity: Minor
    Found in tabbycat/importer/importers/base.py - About 1 day 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 preferences.py has 1012 lines of code (exceeds 600 allowed). Consider refactoring.
    Open

    from django.core.validators import MinValueValidator, validate_slug
    from django.forms import ValidationError
    from django.utils.encoding import force_text
    from django.utils.translation import gettext_lazy as _
    from django_summernote.widgets import SummernoteWidget
    Severity: Major
    Found in tabbycat/options/preferences.py - About 1 day to fix

      File tables.py has 805 lines of code (exceeds 600 allowed). Consider refactoring.
      Open

      import logging
      import warnings
      
      from django.contrib.humanize.templatetags.humanize import ordinal
      from django.utils.encoding import force_text
      Severity: Major
      Found in tabbycat/utils/tables.py - About 6 hrs to fix

        Function add_debate_adjudicators_column has a Cognitive Complexity of 44 (exceeds 8 allowed). Consider refactoring.
        Open

            def add_debate_adjudicators_column(self, debates, title="Adjudicators", show_splits=False, highlight_adj=None):
                da_data = []
        
                def construct_text(adjs_data):
                    adjs_list = []
        Severity: Minor
        Found in tabbycat/utils/tables.py - About 6 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_result has a Cognitive Complexity of 42 (exceeds 8 allowed). Consider refactoring.
        Open

        def add_result(debate, submitter_type, user, discarded=False, confirmed=False, reply_random=False):
            """Adds a ballot set to a debate.
        
            ``debate`` is the Debate to which the ballot set should be added.
            ``submitter_type`` is a valid value of BallotSubmission.submitter_type.
        Severity: Minor
        Found in tabbycat/results/dbutils.py - About 5 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_feedback has a Cognitive Complexity of 42 (exceeds 8 allowed). Consider refactoring.
        Open

        def add_feedback(debate, submitter_type, user, probability=1.0, discarded=False, confirmed=False):
            """Adds feedback to a debate.
            Specifically, adds feedback from both teams on the chair, and from every
            adjudicator on every other adjudicator.
        
        
        Severity: Minor
        Found in tabbycat/adjfeedback/dbutils.py - About 5 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 37 (exceeds 8 allowed). Consider refactoring.
        Open

            def handle_tournament(self, tournament, **options):
        
                compare_tournament = Tournament.objects.get(slug=options['compare'])
                debates = Debate.objects.filter(round__tournament=tournament, round__stage=Round.STAGE_PRELIMINARY)
        
        
        Severity: Minor
        Found in tabbycat/results/management/commands/compareballots.py - About 5 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_speakers has a Cognitive Complexity of 32 (exceeds 8 allowed). Consider refactoring.
        Open

            def clean_speakers(self, cleaned_data):
                """Checks that the speaker selections are valid."""
        
                # Pull team info again, in case it's changed since the form was loaded.
                if self.choosing_sides:
        Severity: Minor
        Found in tabbycat/results/forms.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_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

        TabbycatTableBuilder has 33 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class TabbycatTableBuilder(BaseTableBuilder):
            """Extends TableBuilder to add convenience functions specific to
            Tabbycat."""
        
            ADJ_SYMBOLS = {
        Severity: Minor
        Found in tabbycat/utils/tables.py - About 4 hrs to fix

          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 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

          Function ballots_email_generator has a Cognitive Complexity of 28 (exceeds 8 allowed). Consider refactoring.
          Open

          def ballots_email_generator(to, debate_id):
              emails = []
              debate = Debate.objects.get(id=debate_id)
              tournament = debate.round.tournament
              results = DebateResult(debate.confirmed_ballot)
          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 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 readable_ballotsub_result has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
          Open

          def readable_ballotsub_result(ballotsub):
              """ Make a human-readable representation of a debate result """
          
              def format_dt(dt, t, use_codes):
                  # Translators: e.g. "{Melbourne 1} as {OG}", "{Cape Town 1} as {CO}"
          Severity: Minor
          Found in tabbycat/results/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 DrawGenerator has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
          Open

          def DrawGenerator(teams_per_debate, draw_type, teams, results=None, rrseq=None, **kwargs):  # noqa: N802 (factory function)
              """Factory for draw objects.
              Takes a list of options and returns an appropriate subclass of BaseDrawGenerator.
              'draw_type' is mandatory and can be any of 'random', 'power_paired',
                  'first_elimination' and '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

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

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

            VotingDebateResult has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class VotingDebateResult(BaseDebateResultWithSpeakers):
                """Instantiates a scoresheet for each voting adjudicator, and calculates
                the decision according to a majority vote among them."""
            
                is_voting = True
            Severity: Minor
            Found in tabbycat/results/result.py - About 3 hrs to fix

              Function _result_cell_bp has a Cognitive Complexity of 26 (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 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

              Severity
              Category
              Status
              Source
              Language