TabbycatDebate/tabbycat

View on GitHub
tabbycat/utils/tables.py

Summary

Maintainability
F
1 wk
Test Coverage
F
55%

Function add_debate_adjudicators_column has a Cognitive Complexity of 52 (exceeds 8 allowed). Consider refactoring.
Open

    def add_debate_adjudicators_column(self, debates, title="Adjudicators",
            show_splits=False, highlight_adj=None, for_admin=False):
        da_data = []

        def construct_text(adjs_data):
Severity: Minor
Found in tabbycat/utils/tables.py - About 7 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 tables.py has 810 lines of code (exceeds 600 allowed). Consider refactoring.
Open

import logging
import warnings

from django.contrib.humanize.templatetags.humanize import ordinal
from django.utils.encoding import force_text
Severity: Major
Found in tabbycat/utils/tables.py - About 7 hrs to fix

    TabbycatTableBuilder has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TabbycatTableBuilder(BaseTableBuilder):
        """Extends TableBuilder to add convenience functions specific to
        Tabbycat."""
    
        ADJ_SYMBOLS = {
    Severity: Minor
    Found in tabbycat/utils/tables.py - About 4 hrs to fix

      Function _result_cell_bp has a Cognitive Complexity of 26 (exceeds 8 allowed). Consider refactoring.
      Open

          def _result_cell_bp(self, ts, compress=False, show_score=False, show_ballots=False):
              if not hasattr(ts, 'debate_team'):
                  return {'text': self.BLANK_TEXT}
      
              other_teams = {dt.side: self._team_short_name(dt.team) for dt in ts.debate_team.debate.debateteam_set.all()}
      Severity: Minor
      Found in tabbycat/utils/tables.py - About 3 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_results_columns has a Cognitive Complexity of 26 (exceeds 8 allowed). Consider refactoring.
      Open

          def add_debate_results_columns(self, debates, iron=False):
              all_sides_confirmed = all(debate.sides_confirmed for debate in debates)  # should already be fetched
              side_abbrs = {side: get_side_name(self.tournament, side, 'abbr')
                  for side in self.tournament.sides}
      
      
      Severity: Minor
      Found in tabbycat/utils/tables.py - About 3 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

      Cyclomatic complexity is too high in method _result_cell_bp. (19)
      Open

          def _result_cell_bp(self, ts, compress=False, show_score=False, show_ballots=False):
              if not hasattr(ts, 'debate_team'):
                  return {'text': self.BLANK_TEXT}
      
              other_teams = {dt.side: self._team_short_name(dt.team) for dt in ts.debate_team.debate.debateteam_set.all()}
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function add_speaker_columns has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
      Open

          def add_speaker_columns(self, speakers, categories=True):
              speaker_data = []
              for speaker in speakers:
                  if getattr(speaker, 'anonymise', False):
                      speaker_data.append({'text': "<em>" + _("Redacted") + "</em>", 'class': 'no-wrap'})
      Severity: Minor
      Found in tabbycat/utils/tables.py - About 3 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

      Cyclomatic complexity is too high in method add_debate_results_columns. (18)
      Open

          def add_debate_results_columns(self, debates, iron=False):
              all_sides_confirmed = all(debate.sides_confirmed for debate in debates)  # should already be fetched
              side_abbrs = {side: get_side_name(self.tournament, side, 'abbr')
                  for side in self.tournament.sides}
      
      
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method _result_cell_two. (17)
      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 by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method _team_cell. (14)
      Open

          def _team_cell(self, team, show_emoji=False, subtext=None, highlight=False):
              cell = {
                  'text': self._team_short_name(team),
                  'emoji': team.emoji if show_emoji and self.tournament.pref('show_emoji') else None,
                  'sort': self._team_short_name(team),
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method add_adjudicator_columns. (14)
      Open

          def add_adjudicator_columns(self, adjudicators, show_institutions=True,
                  show_metadata=True, subtext=None):
      
              adj_data = []
              for adj in adjudicators:
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method add_draw_conflicts_columns. (13)
      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 by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method add_debate_ballot_link_column. (13)
      Open

          def add_debate_ballot_link_column(self, debates, show_ballot=False):
              ballot_links_header = {'key': "ballot", 'icon': 'search',
                                     'tooltip': _("The ballot you submitted")}
      
              if self.admin:
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method add_debate_adjudicators_column. (13)
      Open

          def add_debate_adjudicators_column(self, debates, title="Adjudicators",
                  show_splits=False, highlight_adj=None, for_admin=False):
              da_data = []
      
              def construct_text(adjs_data):
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method add_team_columns. (12)
      Open

          def add_team_columns(self, teams, show_break_categories=False, show_emoji=True, key=None):
              """If `show_break_categories` is True, each team must be annotated with
              a `break_categories_nongeneral` attribute, which typically looks like this:
                  Prefetch('break_categories', queryset=BreakCategory.objects.filter(is_general=False),
                      to_attr='break_categories_nongeneral')
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function add_debate_ballot_link_column has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
      Open

          def add_debate_ballot_link_column(self, debates, show_ballot=False):
              ballot_links_header = {'key': "ballot", 'icon': 'search',
                                     'tooltip': _("The ballot you submitted")}
      
              if self.admin:
      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

      Cyclomatic complexity is too high in method add_speaker_columns. (11)
      Open

          def add_speaker_columns(self, speakers, categories=True):
              speaker_data = []
              for speaker in speakers:
                  if getattr(speaker, 'anonymise', False):
                      speaker_data.append({'text': "<em>" + _("Redacted") + "</em>", 'class': 'no-wrap'})
      Severity: Minor
      Found in tabbycat/utils/tables.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function _result_cell_two has a Cognitive Complexity of 17 (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 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 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

        Avoid deeply nested control flow statements.
        Open

                                if cat.public:
                                    category_strs.append(cat.name)
                                elif self.admin:
                                    category_strs.append("<em>" + cat.name + "</em>")
                            categories_data.append(", ".join(category_strs))
        Severity: Major
        Found in tabbycat/utils/tables.py - About 45 mins to fix

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

              def add_debate_motion_column(self, debates):
                  """Shows the motions associated with the debates.
                  The mechanism depends on whether the 'enable_motions' preferences is enabled:
                  if it is, then the motion is attached to the debate's confirmed ballot; if
                  not, then it's just attached to the round."""
          Severity: Minor
          Found in tabbycat/utils/tables.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

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

              def _team_cell(self, team, show_emoji=False, subtext=None, highlight=False):
                  cell = {
                      'text': self._team_short_name(team),
                      'emoji': team.emoji if show_emoji and self.tournament.pref('show_emoji') else None,
                      'sort': self._team_short_name(team),
          Severity: Minor
          Found in tabbycat/utils/tables.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

          Function add_draw_conflicts_columns has a Cognitive Complexity of 11 (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 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

          Function add_debate_adjudicators_column has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def add_debate_adjudicators_column(self, debates, title="Adjudicators",
          Severity: Minor
          Found in tabbycat/utils/tables.py - About 35 mins to fix

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

                def add_adjudicator_columns(self, adjudicators, show_institutions=True,
                        show_metadata=True, subtext=None):
            
                    adj_data = []
                    for adj in adjudicators:
            Severity: Minor
            Found in tabbycat/utils/tables.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 add_metric_columns has a Cognitive Complexity of 10 (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 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 add_motion_column has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
            Open

                def add_motion_column(self, motions, show_order=False):
                    if show_order and self.tournament.pref('enable_motions'):
                        self.add_column({
                            'key': "order",
                            'icon': 'hash',
            Severity: Minor
            Found in tabbycat/utils/tables.py - About 25 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def _result_cell_class_two(self, win, cell):
                    team_name = cell['popover']['title']
                    if win is True:
                        cell['popover']['title'] = _("%(team)s won") % {'team': team_name}
                        cell['icon'] = "chevron-up"
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 1 day to fix
            tabbycat/utils/tables.py on lines 326..342

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 231.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def _result_cell_class_four_elim(self, advancing, cell):
                    team_name = cell['popover']['title']
                    if advancing is True:
                        cell['popover']['title'] = _("%(team)s is advancing") % {'team': team_name}
                        cell['icon'] = "chevron-up"
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 1 day to fix
            tabbycat/utils/tables.py on lines 280..296

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 231.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if show_ballots:
                        if self.admin:
                            cell['popover']['content'].append({
                                'text': _("View/edit debate ballot"),
                                'link': reverse_tournament('old-results-ballotset-edit',
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 6 hrs to fix
            tabbycat/utils/tables.py on lines 452..463

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 121.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if show_ballots:
                        if self.admin:
                            cell['popover']['content'].append({
                                'text': _("View/edit debate ballot"),
                                'link': reverse_tournament('results-ballotset-edit',
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 6 hrs to fix
            tabbycat/utils/tables.py on lines 373..384

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 121.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if show_score and ts.score is not None:
                        score = ts.score
                        if self.tournament.integer_scores(ts.debate_team.debate.round.stage) and score.is_integer():
                            score = int(ts.score)
                        cell['subtext'] = metricformat(score)
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 6 hrs to fix
            tabbycat/utils/tables.py on lines 365..371

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 118.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if show_score and ts.score is not None:
                        score = ts.score
                        if self.tournament.integer_scores(ts.debate_team.debate.round.stage) and score.is_integer():
                            score = int(ts.score)
                        cell['subtext'] = metricformat(score)
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 6 hrs to fix
            tabbycat/utils/tables.py on lines 444..450

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 118.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if len(self.data) > 0 and len(data) != len(self.data):
                        raise ValueError("data contains {new:d} rows, existing table has {existing:d}".format(
                            new=len(data), existing=len(self.data)))
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 1 hr to fix
            tabbycat/utils/tables.py on lines 118..120

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 65.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if len(self.data) > 0 and len(data) != len(self.data):
                        raise ValueError("data contains {new:d} rows, existing table has {existing:d}".format(
                            new=len(data), existing=len(self.data)))
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 1 hr to fix
            tabbycat/utils/tables.py on lines 77..79

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 65.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def add_round_column(self, rounds):
                    header = {
                        'key': "round", 'icon': 'clock', 'tooltip': _("Round"),
                    }
                    data = [{
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 1 hr to fix
            tabbycat/utils/tables.py on lines 468..475

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def add_tournament_column(self, tournaments):
                    header = {
                        'key': "tournament", 'icon': 'tag', 'tooltip': _("Tournament"),
                    }
                    data = [{
            Severity: Major
            Found in tabbycat/utils/tables.py and 1 other location - About 1 hr to fix
            tabbycat/utils/tables.py on lines 477..484

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status