TabbycatDebate/tabbycat

View on GitHub

Showing 439 of 439 total issues

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

    def save_ballot(self):
        # 4. Save the sides
        if self.choosing_sides:
            self.result.set_sides(*self.cleaned_data['choose_sides'])

Severity: Minor
Found in tabbycat/results/forms.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_result has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def add_result(debate, submitter_type, user, discarded=False, confirmed=False, reply_random=False):
Severity: Minor
Found in tabbycat/results/dbutils.py - About 45 mins to fix

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

        def add_ballot_check_in_columns(self, debates, key):
    
            status_header = {
                'key': key,
                'tooltip': _("Whether this debate's ballot has been checked in"),
    Severity: Minor
    Found in tabbycat/results/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_speakers has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
    Open

        def add_speakers(self, side_tag, debate, result, side):
            for pos in self.t.positions:
                speaker = result.get_speaker(side, pos)
    
                if speaker is not None:
    Severity: Minor
    Found in tabbycat/importer/archive.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 _define_rooms_anywhere has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
    Open

        def _define_rooms_anywhere(points):
            """Defines rooms so that pull-up teams can go anywhere in the next
            bracket up."""
            counts = Counter(points)
            rooms = []
    Severity: Minor
    Found in tabbycat/draw/generator/bphungarian.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 handle_tournament has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
    Open

        def handle_tournament(self, tournament, **options):
    
            writer = csv.writer(self.stdout)
    
            headings = [
    Severity: Minor
    Found in tabbycat/actionlog/management/commands/keytimes.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 process_view has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
    Open

        def process_view(self, request, view_func, view_args, view_kwargs):
            if 'tournament_slug' in view_kwargs and request.path.split('/')[1] != 'api':
                cached_key = "%s_%s" % (view_kwargs['tournament_slug'], 'object')
                cached_tournament_object = cache.get(cached_key)
    
    
    Severity: Minor
    Found in tabbycat/utils/middleware.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

    Avoid deeply nested control flow statements.
    Open

                            if field == 'speaker':
                                message += " (original score {})".format(ss.score)
                            self.stdout.write(message)
    Severity: Major
    Found in tabbycat/results/management/commands/compareballots.py - About 45 mins to fix

      Function DrawGenerator has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def DrawGenerator(teams_per_debate, draw_type, teams, results=None, rrseq=None, **kwargs):  # noqa: N802 (factory function)
      Severity: Minor
      Found in tabbycat/draw/generator/__init__.py - About 45 mins to fix

        Function add_feedback has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def add_feedback(debate, submitter_type, user, probability=1.0, discarded=False, confirmed=False):
        Severity: Minor
        Found in tabbycat/adjfeedback/dbutils.py - About 45 mins to fix

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

              def __init__(self, *args, **kwargs):
                  super().__init__(*args, **kwargs)
                  if not is_staff(kwargs.get('context')):
                      t = kwargs['context']['tournament']
                      with_permission = partial(has_permission, user=kwargs['context']['request'].user, tournament=t)
          Severity: Minor
          Found in tabbycat/api/serializers.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_constraint_message has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _add_constraint_message(debate, instance, venue, success_message, failure_message, message_args):
          Severity: Minor
          Found in tabbycat/venues/utils.py - About 45 mins to fix

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

                        for institution_name in line['institution_conflicts'].split(","):
                            institution_name = institution_name.strip()
                            institution = pm.Institution.objects.lookup(institution_name)
                            yield {
                                'adjudicator' : adjudicator,
            Severity: Minor
            Found in tabbycat/importer/importers/anorak.py and 1 other location - About 45 mins to fix
            tabbycat/importer/importers/anorak.py on lines 290..295

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

            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 _print_stage(self, message):
                    if self.verbosity > 0:
                        if self.color:
                            message = "\033[0;36m" + message + "\033[0m\n"
                        self.stdout.write(message)
            Severity: Minor
            Found in tabbycat/importer/management/commands/importtournament.py and 1 other location - About 45 mins to fix
            tabbycat/importer/management/commands/importtournament.py on lines 125..129

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

            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 import_adj_feedback_questions(self, f):
                    interpreter = make_interpreter(
                        tournament=self.tournament,
                        answer_type=self.lookup_feedback_answer_type,
                        choices=lambda c: c.split('//'),
            Severity: Minor
            Found in tabbycat/importer/importers/boots.py and 1 other location - About 45 mins to fix
            tabbycat/importer/importers/anorak.py on lines 343..350

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

            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 _warning(self, message):
                    if self.verbosity > 0:
                        if self.color:
                            message = "\033[0;33mWarning: " + message + "\033[0m\n"
                        self.stdout.write(message)
            Severity: Minor
            Found in tabbycat/importer/management/commands/importtournament.py and 1 other location - About 45 mins to fix
            tabbycat/importer/management/commands/importtournament.py on lines 104..108

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

            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 import_adj_feedback_questions(self, f):
                    question_interpreter = make_interpreter(
                        tournament=self.tournament,
                        answer_type=self.lookup_feedback_answer_type,
                        choices=lambda c: c.split('//'),
            Severity: Minor
            Found in tabbycat/importer/importers/anorak.py and 1 other location - About 45 mins to fix
            tabbycat/importer/importers/boots.py on lines 273..280

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

            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

                        for team_name in line['team_conflicts'].split(","):
                            team_name = team_name.strip()
                            team = pm.Team.objects.lookup(team_name)
                            yield {
                                'adjudicator' : adjudicator,
            Severity: Minor
            Found in tabbycat/importer/importers/anorak.py and 1 other location - About 45 mins to fix
            tabbycat/importer/importers/anorak.py on lines 277..282

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

            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

            Consider simplifying this complex logical expression.
            Open

                if feedback_paths == 'no-adjs':
                    targets = []
                elif feedback_paths == 'all-adjs' or debateadj.type == DebateAdjudicator.TYPE_CHAIR:
                    targets = [(adj, pos) for adj, pos in adjudicators.with_positions() if adj.id != debateadj.adjudicator_id]
                elif feedback_paths == 'with-p-on-p' and debateadj.type == DebateAdjudicator.TYPE_PANEL:
            Severity: Major
            Found in tabbycat/adjfeedback/utils.py - About 40 mins to fix

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

                      if not self.sides_confirmed:
                          teams_list = ", ".join([dt.team.short_name for dt in self.debateteam_set.all()])
                          # Translators: This is appended to a list of teams, e.g. "Auckland
                          # 1, Vic Wellington 1 (sides not confirmed)". Mind the leading
                          # space.
              Severity: Minor
              Found in tabbycat/draw/models.py and 1 other location - About 40 mins to fix
              tabbycat/draw/models.py on lines 108..110

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

              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

              Severity
              Category
              Status
              Source
              Language