TabbycatDebate/tabbycat

View on GitHub

Showing 231 of 446 total issues

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

# -*- coding: utf-8 -*-
import random
import logging
from typing import Tuple, Optional

Severity: Major
Found in tabbycat/participants/emoji.py - About 3 days to fix

    File serializers.py has 1235 lines of code (exceeds 600 allowed). Consider refactoring.
    Open

    from collections import OrderedDict
    from collections.abc import Mapping
    from datetime import date, datetime, time
    from functools import partial, partialmethod
    
    
    Severity: Major
    Found in tabbycat/api/serializers.py - About 2 days to fix

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

      from copy import deepcopy
      from itertools import groupby
      
      from asgiref.sync import async_to_sync
      from channels.layers import get_channel_layer
      Severity: Major
      Found in tabbycat/api/views.py - About 1 day 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

        Function import_results has a Cognitive Complexity of 74 (exceeds 8 allowed). Consider refactoring.
        Open

            def import_results(self):
                for round in self.root.findall('round'):
                    consensus = self.preliminary_consensus if round.get('elimination') == 'false' else self.elimination_consensus
        
                    for debate in round.findall('debate'):
        Severity: Minor
        Found in tabbycat/importer/archive.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

        Function populate_results has a Cognitive Complexity of 67 (exceeds 8 allowed). Consider refactoring.
        Open

        def populate_results(ballotsubs, tournament=None):
            """Populates the `_result` attribute of each BallotSubmission in
            `ballotsubs` with a populated DebateResult instance.
        
            For best performance, the ballot submissions should already have their
        Severity: Minor
        Found in tabbycat/results/prefetch.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 result.py has 862 lines of code (exceeds 600 allowed). Consider refactoring.
        Open

        """Debate result classes.
        
        Debate result classes aggregate scoresheets to produce results for an entire
        debate, and interact with the database with respect to models recording scores
        given in the debate. They do not deal with metadata (like motions), only scores
        Severity: Major
        Found in tabbycat/results/result.py - About 1 day to fix

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

          import logging
          import warnings
          
          from django.contrib.auth.models import AnonymousUser
          from django.contrib.humanize.templatetags.humanize import ordinal
          Severity: Major
          Found in tabbycat/utils/tables.py - About 1 day to fix

            Function setSorting has a Cognitive Complexity of 47 (exceeds 8 allowed). Consider refactoring.
            Open

                setSorting (state, sortType) {
                  let debatesArray = Object.values(state.debatesOrPanels)
            
                  if (debatesArray.length === 0) {
                    return // e.g. Preformed Panels page prior to use
            Severity: Minor
            Found in tabbycat/templates/allocations/DragAndDropStore.js - 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

            File forms.py has 792 lines of code (exceeds 600 allowed). Consider refactoring.
            Open

            import logging
            from decimal import Decimal
            from itertools import product
            from typing import TYPE_CHECKING
            
            
            Severity: Major
            Found in tabbycat/results/forms.py - About 6 hrs to fix

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

                  def add_debate_adjudicators_column(self, debates, title="Adjudicators",
                          show_splits=False, highlight_adj=None, for_admin=False):
                      da_data = []
              
                      def construct_text(adjs_data):
              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_feedback has a Cognitive Complexity of 44 (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 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

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

              import logging
              
              from asgiref.sync import async_to_sync
              from channels.layers import get_channel_layer
              from django.conf import settings
              Severity: Major
              Found in tabbycat/results/views.py - About 5 hrs to fix

                Function add_result has a Cognitive Complexity of 41 (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 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

                TabbycatTableBuilder has 37 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 add_debate_ballot_link_column has a Cognitive Complexity of 33 (exceeds 8 allowed). Consider refactoring.
                  Open

                      def add_debate_ballot_link_column(self, debates, show_ballot=False):
                          ballot_links_header = {'key': "ballot", 'icon': 'search',
                                                 'tooltip': _("The ballot you submitted")}
                          no_ballot = _("No Ballot")
                  
                  
                  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 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 add_debate_results_columns has a Cognitive Complexity of 32 (exceeds 8 allowed). Consider refactoring.
                  Open

                      def add_debate_results_columns(self, debates, iron=False, n_cols=None):
                          all_sides_confirmed = all(debate.sides_confirmed for debate in debates)  # should already be fetched
                          n_cols = n_cols or len(self.tournament.sides)
                          side_abbrs = {side: get_side_name(self.tournament, side, 'abbr') for side in range(n_cols)}
                  
                  
                  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 calculate_anticipated_draw has a Cognitive Complexity of 32 (exceeds 8 allowed). Consider refactoring.
                  Open

                  def calculate_anticipated_draw(round):
                      """Calculates an anticipated draw for the next round, based on the draw for
                      the last round. Returns a list of tuples
                          `(bracket_min, bracket_max, liveness)`,
                      being the minimum and maximum brackets possible for that room, and the
                  Severity: Minor
                  Found in tabbycat/adjallocation/preformed/anticipated.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

                  Severity
                  Category
                  Status
                  Source
                  Language