TabbycatDebate/tabbycat

View on GitHub

Showing 213 of 429 total issues

File emoji.py has 1647 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

    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 serializers.py has 1095 lines of code (exceeds 600 allowed). Consider refactoring.
    Open

    from collections import OrderedDict
    from collections.abc import Mapping
    from functools import partialmethod
    
    from django.contrib.auth import get_user_model
    Severity: Major
    Found in tabbycat/api/serializers.py - About 1 day to fix

      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

      File views.py has 962 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

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

        import logging
        import warnings
        
        from django.contrib.humanize.templatetags.humanize import ordinal
        from django.db.models import Exists, OuterRef, Prefetch
        Severity: Major
        Found in tabbycat/utils/tables.py - About 7 hrs 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

          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

          File result.py has 783 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 6 hrs to fix

            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

            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

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

            import logging
            from itertools import product
            
            from asgiref.sync import async_to_sync
            from channels.layers import get_channel_layer
            Severity: Major
            Found in tabbycat/results/forms.py - About 5 hrs to fix

              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 calculate_anticipated_draw has a Cognitive Complexity of 33 (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

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

                import logging
                from itertools import groupby
                
                from asgiref.sync import async_to_sync
                from channels.layers import get_channel_layer
                Severity: Major
                Found in tabbycat/results/views.py - About 4 hrs to fix

                  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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language