TabbycatDebate/tabbycat

View on GitHub

Showing 231 of 446 total issues

Function __init__ has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def __init__(self, result, adj, side, pos):
        self.speaker = result.get_speaker(side, pos)
        self.ghost = result.get_ghost(side, pos)

        if adj is None:
Severity: Minor
Found in tabbycat/results/result_info.py - About 35 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 liveness has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

def liveness(self, team, teams_count, prelims, current_round):
    live_info = {'text': team.wins_count, 'tooltip': ''}

    # The actual calculation should be shifted to be a cached method on
    # the relevant break category
Severity: Minor
Found in tabbycat/breakqual/utils.py - About 35 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_rounds has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def get_rounds(self, options):
        """Returns a list of rounds implied by command-line arguments.
        Implementation note: For caching purposes, this stores the result in
        the "__rounds__" key of the options dict."""

Severity: Minor
Found in tabbycat/utils/management/base.py - About 35 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 dispatch has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def dispatch(self, request, *args, **kwargs):
        t = self.tournament

        if not getattr(settings, 'DISABLE_SENTRY', False):
            from sentry_sdk import set_context
Severity: Minor
Found in tabbycat/tournaments/mixins.py - About 35 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 cast_round_results has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def cast_round_results(self, standings, rounds, step_preference):
        """For use by subclasses. Casts round results to integers if appropriate
        according to tournament preferences."""
        if self.tournament.pref(step_preference) % 1 == 0:
            is_consensus_by_round = [self.tournament.ballots_per_debate(r.stage) == 'per-debate' for r in rounds]
Severity: Minor
Found in tabbycat/standings/views.py - About 35 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 run_allocation has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def run_allocation(self):

        # Sort voting adjudicators in descending order by score
        voting = [a for a in self.adjudicators if a._weighted_score >= self.min_voting_score and not a.trainee]
        random.shuffle(voting)
Severity: Minor
Found in tabbycat/adjallocation/allocators/hungarian.py - About 35 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 __init__ has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def __init__(self, *args, **kwargs):
        self.fields['speakers'] = self.TeamSpeakerSerializer(*args, many=True, required=False, **kwargs)

        super().__init__(*args, **kwargs)

Severity: Minor
Found in tabbycat/api/serializers.py - About 35 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 email has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def email(self, event: Dict[str, Union[str, BulkNotification.EventType, List[int], Dict[str, Any]]]) -> None:
        # Get database objects
        if 'debate_id' in event['extra']:
            debate = Debate.objects.select_related('round__tournament').get(pk=event['extra'].pop('debate_id'))
            event['extra']['debate'] = debate
Severity: Minor
Found in tabbycat/notifications/consumers.py - About 35 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

Avoid too many return statements within this function.
Open

                return GraphPowerPairedDrawGenerator
Severity: Major
Found in tabbycat/draw/generator/__init__.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return obj.name
    Severity: Major
    Found in tabbycat/actionlog/models.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return self.error_page(_("Your debate doesn't have a chair, so you can't enter results for it. "
      Severity: Major
      Found in tabbycat/results/views.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                            return obj.debate.matchup
        Severity: Major
        Found in tabbycat/actionlog/models.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return super().post(request, *args, **kwargs)
          Severity: Major
          Found in tabbycat/checkins/views.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return "first_elimination"
            Severity: Major
            Found in tabbycat/draw/manager.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return super().post(request, *args, **kwargs)
              Severity: Major
              Found in tabbycat/draw/views.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return gettext("result unknown")
                Severity: Major
                Found in tabbycat/draw/models.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return obj.reference
                  Severity: Major
                  Found in tabbycat/actionlog/models.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return self.error_page(_("It looks like the sides for this debate haven't yet been confirmed, "
                    Severity: Major
                    Found in tabbycat/results/views.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return "danger", "still-bad", 2
                      Severity: Major
                      Found in tabbycat/draw/tables.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return "<error displaying %s>" % model_name
                        Severity: Major
                        Found in tabbycat/actionlog/models.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language