TabbycatDebate/tabbycat

View on GitHub

Showing 317 of 2,294 total issues

File emoji.py has 1465 lines of code (exceeds 250 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

    File preferences.py has 1154 lines of code (exceeds 250 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 2 days to fix

      File tables.py has 835 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      import warnings
      
      from django.utils import formats
      from django.utils.encoding import force_text
      Severity: Major
      Found in tabbycat/utils/tables.py - About 2 days to fix

        File views.py has 776 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

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

          Function _import has a Cognitive Complexity of 90 (exceeds 5 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 views.py has 679 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            File result.py has 638 lines of code (exceeds 250 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 forms.py has 609 lines of code (exceeds 250 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 1 day to fix

                File views.py has 525 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

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

                  File powerpair.py has 513 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import random
                  from collections import OrderedDict
                  
                  from django.utils.translation import gettext as _
                  
                  
                  Severity: Major
                  Found in tabbycat/draw/generator/powerpair.py - About 1 day to fix

                    File views.py has 492 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import json
                    import logging
                    
                    from django.conf import settings
                    from django.contrib import messages
                    Severity: Minor
                    Found in tabbycat/standings/views.py - About 7 hrs to fix

                      File models.py has 490 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      from django.db import models
                      from django.db.models import Count, Prefetch, Q
                      from django.core.cache import cache
                      from django.core.exceptions import ValidationError
                      from django.urls import reverse
                      Severity: Minor
                      Found in tabbycat/tournaments/models.py - About 7 hrs to fix

                        File mixins.py has 460 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import json
                        import logging
                        
                        from asgiref.sync import async_to_sync
                        from django.conf import settings
                        Severity: Minor
                        Found in tabbycat/tournaments/mixins.py - About 7 hrs to fix

                          Function add_debate_adjudicators_column has a Cognitive Complexity of 44 (exceeds 5 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_feedback has a Cognitive Complexity of 42 (exceeds 5 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 405 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import json
                          import logging
                          
                          from django.contrib import messages
                          from django.db.models import Prefetch, Q
                          Severity: Minor
                          Found in tabbycat/adjallocation/views.py - About 5 hrs to fix

                            Function handle_tournament has a Cognitive Complexity of 37 (exceeds 5 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 add_debate_venue_columns has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def add_debate_venue_columns(self, debates, with_times=True, for_admin=False):
                            
                                    def construct_venue_cell(venue):
                                        if not venue:
                                            return {'text': ''}
                            Severity: Minor
                            Found in tabbycat/utils/tables.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 models.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import logging
                            from warnings import warn
                            
                            from django.contrib.contenttypes.fields import GenericRelation
                            from django.core.exceptions import ValidationError
                            Severity: Minor
                            Found in tabbycat/participants/models.py - About 5 hrs to fix

                              Function clean_speakers has a Cognitive Complexity of 32 (exceeds 5 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

                              Severity
                              Category
                              Status
                              Source
                              Language