TabbycatDebate/tabbycat

View on GitHub

Showing 231 of 446 total issues

Function handle_round has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

    def handle_round(self, round, **options):
        panels = round.preformedpanel_set.all()
        debates = round.debate_set.all()

        allocator_class = registry[options["allocator"]]

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_queryset has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

    def get_queryset(self):
        query_params = self.request.query_params
        filters = Q()

        # Disallow querying for feedback that they didn't submit
Severity: Minor
Found in tabbycat/api/views.py - About 1 hr 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_metric_columns has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

    def add_metric_columns(self, standings, integer_score_columns=[]):
        """`integer_score_columns`, if given, indicates which metrics to cast to
        an int if the metric's value is an integer. For example, if the
        tournament preferences are such that the total speaker score should
        always be an integer, a list containing the string 'total' or
Severity: Minor
Found in tabbycat/utils/tables.py - About 1 hr 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 generate has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

    def generate(cls, to: 'QuerySet[Person]', url: str, round: 'Round') -> List[Tuple[EmailContextData, 'Person']]:
        emails = []
        to_ids = {p.id for p in to}
        draw = round.debate_set_with_prefetches(speakers=False).filter(debateadjudicator__adjudicator__in=to)
        use_codes = use_team_code_names(round.tournament, False)
Severity: Minor
Found in tabbycat/notifications/utils.py - About 1 hr 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

Consider simplifying this complex logical expression.
Open

            if show_splits and self.tournament.ballots_per_debate(debate.round.stage) == 'per-adj' \
                    and debate.confirmed_ballot \
                    and debate.confirmed_ballot.result.is_voting \
                    and debate.confirmed_ballot.result.is_valid() \
                    and (self.admin or self.tournament.pref('show_splitting_adjudicators')):
Severity: Major
Found in tabbycat/utils/tables.py - About 1 hr to fix

    Function make_feedback_form_class_for_team has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def make_feedback_form_class_for_team(source, tournament, submission_fields, confirm_on_submit=False,
    Severity: Major
    Found in tabbycat/adjfeedback/forms.py - About 1 hr to fix

      Function make_feedback_form_class_for_adj has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def make_feedback_form_class_for_adj(source, tournament, submission_fields, confirm_on_submit=False,
      Severity: Major
      Found in tabbycat/adjfeedback/forms.py - About 1 hr to fix

        Function import_teams has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def import_teams(self):
                self.teams = {}
                for team in self.root.findall('participants/team'):
                    team_obj = Team(tournament=self.tournament, long_name=team.get('name'))
                    self.teams[team.get('id')] = team_obj
        Severity: Minor
        Found in tabbycat/importer/archive.py - About 55 mins 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_result_with_scores has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def populate_result_with_scores(self, result):
                for adj in self.adjudicators:
                    for side, pos in product(self.sides, self.positions):
                        score = self.cleaned_data[self._fieldname_score(adj, side, pos)]
                        for criterion in self.criteria:
        Severity: Minor
        Found in tabbycat/results/forms.py - About 55 mins 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 _result_cell_two has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def _result_cell_two(self, ts, compress=False, show_score=False, show_ballots=False):
                if not hasattr(ts, 'debate_team') or not hasattr(ts.debate_team.opponent, 'team'):
                    return {'text': self.BLANK_TEXT}
        
                opp = ts.debate_team.opponent.team
        Severity: Minor
        Found in tabbycat/utils/tables.py - About 55 mins 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 generate_pairings has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def generate_pairings(self, brackets):
                """Creates an undirected weighted graph for each bracket and gets the minimum weight matching"""
                from .pairing import Pairing
                pairings = OrderedDict()
                i = 0
        Severity: Minor
        Found in tabbycat/draw/generator/graph.py - About 55 mins 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_context_data has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def get_context_data(self, **kwargs):
        
                team_codes = use_team_code_names(self.tournament, admin=self.for_admin, user=self.request.user)
                kwargs["team_codes"] = json.dumps(team_codes)
        
        
        Severity: Minor
        Found in tabbycat/checkins/views.py - About 55 mins 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 _print_result has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def _print_result(self):
                if self.verbosity > 0:
                    counts = self.importer.counts
                    errors = self.importer.errors
                    if errors:
        Severity: Minor
        Found in tabbycat/importer/management/commands/importtournament.py - About 55 mins 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_breaking_teams_dict has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def _get_breaking_teams_dict(self):
                if self.round.break_category is None:
                    self.error_type = 'no_break_category'
                    return {
                        'total': 0,
        Severity: Minor
        Found in tabbycat/availability/views.py - About 55 mins 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 12 (exceeds 8 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 55 mins 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 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def clean(self):
                cleaned_data = super().clean()
        
                elim_fields = ['elim_' + category.slug for category in self.tournament.breakcategory_set.all()]
        
        
        Severity: Minor
        Found in tabbycat/tournaments/forms.py - About 55 mins 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 to_internal_value has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def to_internal_value(self, data):
                """
                Dict of native values <- Dict of primitive datatypes.
        
                Copied from DRF while waiting for #8001/#7671 as the format is nested
        Severity: Minor
        Found in tabbycat/api/serializers.py - About 55 mins 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 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def handle_tournament(self, tournament, **options):
        
                def institution_name(inst):
                    if options['full_institution_name']:
                        return inst.name
        Severity: Minor
        Found in tabbycat/adjallocation/management/commands/conflictscsv.py - About 55 mins 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_standing_columns has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _add_debate_standing_columns(self, debates, standings, itermethod, infomethod, formattext, formatsort, limit=None):
        Severity: Major
        Found in tabbycat/draw/tables.py - About 50 mins to fix

          Function process_view has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
          Open

              def process_view(self, request, view_func, view_args, view_kwargs):
                  if 'tournament_slug' in view_kwargs and request.path.split('/')[1] != 'api':
                      cached_key = "%s_%s" % (view_kwargs['tournament_slug'], 'object')
                      cached_tournament_object = cache.get(cached_key)
          
          
          Severity: Minor
          Found in tabbycat/utils/middleware.py - About 45 mins 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