TabbycatDebate/tabbycat

View on GitHub

Showing 428 of 428 total issues

Avoid too many return statements within this function.
Open

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

    Avoid too many return statements within this function.
    Open

                    return redirect_tournament('tournament-public-index', t)
    Severity: Major
    Found in tabbycat/tournaments/mixins.py - About 30 mins to fix

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

      class AdjudicatorFeedbackStringAnswer(AdjudicatorFeedbackAnswer):
          ANSWER_TYPE = str
          answer = models.TextField(verbose_name=_("answer"))
      
          class Meta(AdjudicatorFeedbackAnswer.Meta):
      Severity: Major
      Found in tabbycat/adjfeedback/models.py and 3 other locations - About 30 mins to fix
      tabbycat/adjfeedback/models.py on lines 40..50
      tabbycat/adjfeedback/models.py on lines 53..60
      tabbycat/adjfeedback/models.py on lines 63..70

      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 50.

      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

      Avoid too many return statements within this function.
      Open

                  return redirect_round('availability-index', self.round.next)
      Severity: Major
      Found in tabbycat/tournaments/views.py - About 30 mins to fix

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

        class AdjudicatorFeedbackBooleanAnswer(AdjudicatorFeedbackAnswer):
            ANSWER_TYPE = bool
        
            # Note: by convention, if no answer is chosen for a boolean answer, an
            # instance of this object should not be created. This way, there is no need
        Severity: Major
        Found in tabbycat/adjfeedback/models.py and 3 other locations - About 30 mins to fix
        tabbycat/adjfeedback/models.py on lines 53..60
        tabbycat/adjfeedback/models.py on lines 63..70
        tabbycat/adjfeedback/models.py on lines 73..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 50.

        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 4 locations. Consider refactoring.
        Open

        class AdjudicatorFeedbackFloatAnswer(AdjudicatorFeedbackAnswer):
            ANSWER_TYPE = float
        
            answer = models.FloatField(verbose_name=_("answer"))
        
        
        Severity: Major
        Found in tabbycat/adjfeedback/models.py and 3 other locations - About 30 mins to fix
        tabbycat/adjfeedback/models.py on lines 40..50
        tabbycat/adjfeedback/models.py on lines 53..60
        tabbycat/adjfeedback/models.py on lines 73..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 50.

        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 4 locations. Consider refactoring.
        Open

        class AdjudicatorFeedbackIntegerAnswer(AdjudicatorFeedbackAnswer):
            ANSWER_TYPE = int
        
            answer = models.IntegerField(verbose_name=_("answer"))
        
        
        Severity: Major
        Found in tabbycat/adjfeedback/models.py and 3 other locations - About 30 mins to fix
        tabbycat/adjfeedback/models.py on lines 40..50
        tabbycat/adjfeedback/models.py on lines 63..70
        tabbycat/adjfeedback/models.py on lines 73..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 50.

        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

        Avoid too many return statements within this function.
        Open

                    return None
        Severity: Major
        Found in tabbycat/adjallocation/allocation.py - About 30 mins to fix

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

              class Meta:
                  unique_together = [('tournament', 'seq'), ('tournament', 'slug')]
                  ordering = ['tournament', 'seq']
                  index_together = ['tournament', 'seq']
                  verbose_name = _("break category")
          Severity: Minor
          Found in tabbycat/breakqual/models.py and 1 other location - About 30 mins to fix
          tabbycat/participants/models.py on lines 83..88

          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 50.

          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

              class Meta:
                  unique_together = [('tournament', 'seq'), ('tournament', 'slug')]
                  ordering = ['tournament', 'seq']
                  index_together = ['tournament', 'seq']
                  verbose_name = _("speaker category")
          Severity: Minor
          Found in tabbycat/participants/models.py and 1 other location - About 30 mins to fix
          tabbycat/breakqual/models.py on lines 53..58

          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 50.

          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

          Function _pullup has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def _pullup(self, brackets, pos):
                  """'brackets' is what is returned by _make_raw_brackets().
                  'pos' is a function taking the number of teams to choose from,
                  and returning an index for which team to take as the pullup.
                  Operates in-place. Does not remove empty brackets."""
          Severity: Minor
          Found in tabbycat/draw/generator/powerpair.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

          Function make_pairings has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def make_pairings(self, rooms, indices):
                  """Creates the BPPairing objects. Also flags pull-up rooms."""
                  teams_in_room = [[None, None, None, None] for i in range(len(indices) // 4)]
                  for t, r in indices:
                      teams_in_room[r // 4][r % 4] = self.teams[t]
          Severity: Minor
          Found in tabbycat/draw/generator/bphungarian.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

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

              def __init__(self, view=None, **kwargs):
                  """Constructor.
                  - If `tournament` is specified, it becomes the default tournament for
                    the builder.
                  - If `admin` is True (default is False), then relevant links will go
          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

          Function get_result_display has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def get_result_display(self):
                  if self.team.tournament.pref('teams_in_debate') == 'bp':
                      if self.points is not None:
                          return gettext("placed %(place)s") % {'place': ordinal(4 - self.points)}
                      else:
          Severity: Minor
          Found in tabbycat/draw/models.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

          Function get_table has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def get_table(cls, view, participant):
                  """On team record pages, the table is the results table."""
          
                  table = TeamResultTableBuilder(view=view, title=view.table_title, sort_key="round")
          
          
          Severity: Minor
          Found in tabbycat/participants/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

          Function side_and_position_names has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

          def side_and_position_names(tournament):
              """Yields 2-tuples (side, positions), where position is a list of position
              names, all being translated human-readable names. This should eventually
              be extended to return an appropriate list for the tournament configuration.
              """
          Severity: Minor
          Found in tabbycat/results/utils.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

          Function setUp has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def setUp(self):
                  super().setUp()
                  # add test models
                  self.tournament = Tournament.objects.create(slug="tournament")
                  for i in range(4):
          Severity: Minor
          Found in tabbycat/utils/tests.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

          Function assignment_cost has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def assignment_cost(self, t1, t2, size, bracket=None):
                  penalty = super().assignment_cost(t1, t2, size)
                  if penalty is None:
                      return None
          
          
          Severity: Minor
          Found in tabbycat/draw/generator/powerpair.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

          Function import_motions has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def import_motions(self):
                  # Can cause data consistency problems if motions are re-used between rounds: See #645
                  self.motions = {}
          
                  motions_by_round = {}
          Severity: Minor
          Found in tabbycat/importer/archive.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

          Function _collate_elim_motion_annotations has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
          Open

              def _collate_elim_motion_annotations(self):
                  """Collect annotations (which will be attributes) and convert them to
                  dictionaries to allow for easy iteration in the template."""
          
                  for motion in self.elim_motions_dict.values():
          Severity: Minor
          Found in tabbycat/motions/statistics.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

          Severity
          Category
          Status
          Source
          Language