TabbycatDebate/tabbycat

View on GitHub

Showing 213 of 429 total issues

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

    def update_with_validation_error(self, lineno, model, ve):
        """Adds the information in a Django ValidationError to this error."""
        if hasattr(ve, 'error_dict'):
            for field, error_list in list(ve.error_dict.items()):
                for error in error_list:
Severity: Minor
Found in tabbycat/importer/importers/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 clean_institutions_raw has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def clean_institutions_raw(self):
        lines = self.cleaned_data['institutions_raw'].split('\n')
        errors = []
        institutions = []

Severity: Minor
Found in tabbycat/importer/forms.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, teams, results=None, rrseq=None, **kwargs):
        self.teams = teams
        self.team_flags = dict()
        self.results = results
        self.rrseq = rrseq
Severity: Minor
Found in tabbycat/draw/generator/common.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 populate_code_names_from_emoji has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

def populate_code_names_from_emoji(teams, overwrite=True):
    """Populates team code names based on existing emoji."""
    count = 0

    for team in teams:
Severity: Minor
Found in tabbycat/participants/emoji.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 handle_tournament has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def handle_tournament(self, tournament, **options):
        for bsub in BallotSubmission.objects.filter(debate__round__tournament=tournament):
            debate_status = bsub.debate.result_status
            original = (bsub.discarded, bsub.confirmed)
            if debate_status == Debate.STATUS_NONE:
Severity: Minor
Found in tabbycat/results/management/commands/fixballotstatuses.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 readable_ballotsub_result has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

def readable_ballotsub_result(debateresult):
    """ Make a human-readable representation of a debate result """

    def get_display_name(dt, t, use_codes):
        return {
Severity: Minor
Found in tabbycat/results/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 allTeams has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    allTeams: state => {
      let teams = {}
      for (let debateOrPanelID in state.debatesOrPanels) {
        let debateOrPanel = state.debatesOrPanels[debateOrPanelID]
        if ('teams' in debateOrPanel) {
Severity: Minor
Found in tabbycat/templates/allocations/DragAndDropStore.js - 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_position_cost_function_str has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

    def get_position_cost_function_str(self):
        cost_func = self.tournament.pref('bp_position_cost')
        if cost_func == 'entropy':
            renyi_order = self.tournament.pref('bp_renyi_order')
            cost_func_str = _("Rényi entropy of order %(order)s" % {'order': renyi_order})
Severity: Minor
Found in tabbycat/draw/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 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 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 validate has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

        def validate(self, data):
            # Convert answer to correct type
            model = AdjudicatorFeedbackQuestion.ANSWER_TYPE_CLASSES[data['question'].answer_type]
            if type(data['answer']) != model.ANSWER_TYPE:
                raise serializers.ValidationError({'answer': 'The answer must be of type %s' % model.ANSWER_TYPE.__name__})
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 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 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 SwapRandomDrawGenerator
Severity: Major
Found in tabbycat/draw/generator/__init__.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return AustralsPowerPairedWithAllocatedSidesDrawGenerator
    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.adjudicator.name + " (" + str(obj.score) + ")"
      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 "<error displaying %s>" % model_name
          Severity: Major
          Found in tabbycat/actionlog/models.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
              Severity
              Category
              Status
              Source
              Language