TabbycatDebate/tabbycat

View on GitHub

Showing 211 of 428 total issues

Function get_tables has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
Open

    def get_tables(self) -> List[TabbycatTableBuilder]:
        tables = []

        # notifications.sentmessage_set.first().emailstatus_set.first().latest_statuses will be a list
        notifications = self.tournament.bulknotification_set.select_related(
Severity: Minor
Found in tabbycat/notifications/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 _interpret_metrics has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
Open

    def _interpret_metrics(self, metrics, extra_metrics):
        """Given a list of metric keys, sets:
            - `self.precedence` to a copy of `metrics` with repeated metric annotators numbered
            - `self.metric_annotators` to the appropriate metric annotators
        For example:
Severity: Minor
Found in tabbycat/standings/base.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 prioritise_panels has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
Open

    def prioritise_panels(self, event):
        rd = Round.objects.get(pk=event['extra']['round_id'])
        panels = rd.preformedpanel_set.all()
        priority_method = event['extra']['settings']['type']

Severity: Minor
Found in tabbycat/adjallocation/consumers.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 prioritise_debates has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
Open

    def prioritise_debates(self, event):
        # TODO: Debates and panels should really be unified in a single function
        round = Round.objects.get(pk=event['extra']['round_id'])
        debates = round.debate_set_with_prefetches(teams=True, adjudicators=False,
            speakers=False, venues=False)
Severity: Minor
Found in tabbycat/adjallocation/consumers.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 get_context_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_context_data(self, **kwargs):
        t = self.tournament
        adjudicators = self.get_adjudicators()
        weight = t.current_round.feedback_weight
        scores = [a.weighted_score(weight) for a in adjudicators]
Severity: Minor
Found in tabbycat/adjfeedback/views.py - About 1 hr to fix

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

        def handle_tournament(self, tournament, **options):
            for team in tournament.team_set.all():
                if team.reference.startswith(team.institution.code + " "):
                    new_reference = team.reference[len(team.institution.code):].strip()
                    self.stdout.write("{verb} team {!r} from {} to {!r}".format(
    Severity: Minor
    Found in tabbycat/participants/management/commands/convertteamnames.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 import_speakers has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def import_speakers(self, f, auto_create_teams=True):
            """Imports speakers, also creating teams as needed (unless
            'auto_create_teams' is False). Institutions are not created as needed;
            if an institution doesn't exist, an error is raised.
            """
    Severity: Minor
    Found in tabbycat/importer/importers/anorak.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 populate_objects has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def populate_objects(self, prefill=True):
            self.object = self.get_object() # must be populated before self.error_page() called
    
            if self.round.draw_status != Round.Status.RELEASED:
                return self.error_page(_("The draw for this round hasn't been released yet."))
    Severity: Minor
    Found in tabbycat/results/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_draw_conflicts_columns has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def add_draw_conflicts_columns(self, debates, venue_conflicts, adjudicator_conflicts):
    
            conflicts_by_debate = []
            for debate in debates:
                # conflicts is a list of (level, message) tuples
    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 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 clean_scoresheet has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def clean_scoresheet(self, cleaned_data):
            for adj in self.adjudicators:
                try:
                    side_totals = {side: sum(cleaned_data[self._fieldname_score(adj, side, pos)]
                               for pos in self.positions) for side in self.sides}
    Severity: Minor
    Found in tabbycat/results/forms.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 get_url_args has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

    def get_url_args(parser, token):
        """Helper function, returns the arguments necessary to construct a URL node.
        This code is copied directly from `url` in django/template/defaulttags.py,
        except that instead of constructing a URL node with the identified
        parameters, it simply returns the parameters in a tuple.
    Severity: Minor
    Found in tabbycat/utils/templatetags/debate_tags.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 get_feedbacks has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def get_feedbacks(self):
            feedbacks = self.get_feedback_queryset()
    
            populate_debate_adjudicators(feedbacks)
            populate_wins_for_debateteams([f.source_team for f in feedbacks if f.source_team is not None])
    Severity: Minor
    Found in tabbycat/adjfeedback/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 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

    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

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

          Severity
          Category
          Status
          Source
          Language