TabbycatDebate/tabbycat

View on GitHub

Showing 446 of 446 total issues

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

    if admin:
        url = reverse_tournament('participants-team-record', context['tournament'], kwargs={'pk': team.pk})
    else:
        url = reverse_tournament('participants-public-team-record', context['tournament'], kwargs={'pk': team.pk})
Severity: Major
Found in tabbycat/participants/templatetags/participant_link.py and 1 other location - About 1 hr to fix
tabbycat/participants/templatetags/participant_link.py on lines 39..42

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

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 admin:
        url = reverse_tournament('participants-adjudicator-record', context['tournament'], kwargs={'pk': adj.pk})
    else:
        url = reverse_tournament('participants-public-adjudicator-record', context['tournament'], kwargs={'pk': adj.pk})
Severity: Major
Found in tabbycat/participants/templatetags/participant_link.py and 1 other location - About 1 hr to fix
tabbycat/participants/templatetags/participant_link.py on lines 23..26

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

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

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

            for team in debate.teams:
                cost += self.conflict_penalty * self.conflicts.conflict_adj_team(adj, team)
                cost += self.history_penalty * self.history.seen_adj_team(adj, team)
    Severity: Major
    Found in tabbycat/adjallocation/allocators/hungarian.py and 1 other location - About 1 hr to fix
    tabbycat/adjallocation/preformed/hungarian.py on lines 31..34

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

    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

            for adj in panel.adjudicators.all():
                for team in debate.teams:
                    cost += self.conflict_penalty * self.conflicts.conflict_adj_team(adj, team)
                    cost += self.history_penalty * self.history.seen_adj_team(adj, team)
    Severity: Major
    Found in tabbycat/adjallocation/preformed/hungarian.py and 1 other location - About 1 hr to fix
    tabbycat/adjallocation/allocators/hungarian.py on lines 72..74

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

    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 make_feedback_form_class_for_team has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def make_feedback_form_class_for_team(source, tournament, submission_fields, confirm_on_submit=False,
    Severity: Major
    Found in tabbycat/adjfeedback/forms.py - About 1 hr to fix

      Function make_feedback_form_class_for_adj has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def make_feedback_form_class_for_adj(source, tournament, submission_fields, confirm_on_submit=False,
      Severity: Major
      Found in tabbycat/adjfeedback/forms.py - About 1 hr to fix

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

                    if f.source_adjudicator:
                        adj = f.source_adjudicator.adjudicator
                        row.extend([adj.id, adj.name, f.source_adjudicator.get_type_display()])
                    else:
                        row.extend([""] * 3)
        Severity: Major
        Found in tabbycat/adjfeedback/views.py and 1 other location - About 1 hr to fix
        tabbycat/adjfeedback/views.py on lines 888..892

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

        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 f.source_team:
                        team = f.source_team.team
                        row.extend([team.id, team.short_name, f.source_team.get_result_display()])
                    else:
                        row.extend([""] * 3)
        Severity: Major
        Found in tabbycat/adjfeedback/views.py and 1 other location - About 1 hr to fix
        tabbycat/adjfeedback/views.py on lines 882..886

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

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

            def import_teams(self):
                self.teams = {}
                for team in self.root.findall('participants/team'):
                    team_obj = Team(tournament=self.tournament, long_name=team.get('name'))
                    self.teams[team.get('id')] = team_obj
        Severity: Minor
        Found in tabbycat/importer/archive.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

        Function populate_result_with_scores has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def populate_result_with_scores(self, result):
                for adj in self.adjudicators:
                    for side, pos in product(self.sides, self.positions):
                        score = self.cleaned_data[self._fieldname_score(adj, side, pos)]
                        for criterion in self.criteria:
        Severity: Minor
        Found in tabbycat/results/forms.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

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

        Function generate_pairings has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def generate_pairings(self, brackets):
                """Creates an undirected weighted graph for each bracket and gets the minimum weight matching"""
                from .pairing import Pairing
                pairings = OrderedDict()
                i = 0
        Severity: Minor
        Found in tabbycat/draw/generator/graph.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

        Function get_context_data has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def get_context_data(self, **kwargs):
        
                team_codes = use_team_code_names(self.tournament, admin=self.for_admin, user=self.request.user)
                kwargs["team_codes"] = json.dumps(team_codes)
        
        
        Severity: Minor
        Found in tabbycat/checkins/views.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

        Function _print_result has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def _print_result(self):
                if self.verbosity > 0:
                    counts = self.importer.counts
                    errors = self.importer.errors
                    if errors:
        Severity: Minor
        Found in tabbycat/importer/management/commands/importtournament.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

        Function _get_breaking_teams_dict has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def _get_breaking_teams_dict(self):
                if self.round.break_category is None:
                    self.error_type = 'no_break_category'
                    return {
                        'total': 0,
        Severity: Minor
        Found in tabbycat/availability/views.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

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

                if http_prefix:
                    # If needed, convert absolute URLs to relative path
                    data = parse.urlparse(data).path
                    prefix = get_script_prefix()
                    if data.startswith(prefix):
        Severity: Minor
        Found in tabbycat/api/fields.py and 1 other location - About 55 mins to fix
        tabbycat/api/fields.py on lines 254..259

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

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

        Function clean has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def clean(self):
                cleaned_data = super().clean()
        
                elim_fields = ['elim_' + category.slug for category in self.tournament.breakcategory_set.all()]
        
        
        Severity: Minor
        Found in tabbycat/tournaments/forms.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

        Function to_internal_value has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Open

            def to_internal_value(self, data):
                """
                Dict of native values <- Dict of primitive datatypes.
        
                Copied from DRF while waiting for #8001/#7671 as the format is nested
        Severity: Minor
        Found in tabbycat/api/serializers.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

        Severity
        Category
        Status
        Source
        Language