TabbycatDebate/tabbycat

View on GitHub
tabbycat/adjallocation/consumers.py

Summary

Maintainability
D
2 days
Test Coverage

Function allocate_debate_adjs has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
Open

    def allocate_debate_adjs(self, event):
        round = Round.objects.get(pk=event['extra']['round_id'])
        self._apply_allocation_settings(round, event['extra']['settings'])

        if round.draw_status == round.Status.RELEASED:
Severity: Minor
Found in tabbycat/adjallocation/consumers.py - About 2 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 prioritise_debates has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
Open

    def prioritise_debates(self, event):
        # TODO: Debates and panels should really be unified in a single function
        round = Round.objects.get(pk=event['extra']['round_id'])
        debates = round.debate_set_with_prefetches(teams=True, adjudicators=False,
            speakers=False, venues=False)
Severity: Minor
Found in tabbycat/adjallocation/consumers.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

Function prioritise_panels has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
Open

    def prioritise_panels(self, event):
        rd = Round.objects.get(pk=event['extra']['round_id'])
        panels = rd.preformedpanel_set.all()
        priority_method = event['extra']['settings']['type']

Severity: Minor
Found in tabbycat/adjallocation/consumers.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

TODO found
Open

        # TODO: Debates and panels should really be unified in a single function
Severity: Minor
Found in tabbycat/adjallocation/consumers.py by fixme

TODO found
Open

        # TODO: return debates directly from allocator function?
Severity: Minor
Found in tabbycat/adjallocation/consumers.py by fixme

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

        if user_warnings:
            msg = ngettext(
                "Successfully auto-allocated adjudicators to preformed panels. However, there was a warning:",
                "Successfully auto-allocated adjudicators to preformed panels. However, there were %(count)d warnings:",
                len(user_warnings)) % {'count': len(user_warnings)}
Severity: Major
Found in tabbycat/adjallocation/consumers.py and 1 other location - About 3 hrs to fix
tabbycat/adjallocation/consumers.py on lines 111..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 88.

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 user_warnings:
                msg = ngettext(
                    "Successfully auto-allocated adjudicators to debates. However, there was a warning:",
                    "Successfully auto-allocated adjudicators to debates. However, there were %(count)d warnings:",
                    len(user_warnings)) % {'count': len(user_warnings)}
Severity: Major
Found in tabbycat/adjallocation/consumers.py and 1 other location - About 3 hrs to fix
tabbycat/adjallocation/consumers.py on lines 157..166

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

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

        try:
            if round.ballots_per_debate == 'per-adj':
                allocator = VotingHungarianAllocator(panels, adjs, round)
            else:
                allocator = ConsensusHungarianAllocator(panels, adjs, round)
Severity: Major
Found in tabbycat/adjallocation/consumers.py and 1 other location - About 3 hrs to fix
tabbycat/adjallocation/consumers.py on lines 96..104

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

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

            try:
                if round.ballots_per_debate == 'per-adj':
                    allocator = VotingHungarianAllocator(debates, adjs, round)
                else:
                    allocator = ConsensusHungarianAllocator(debates, adjs, round)
Severity: Major
Found in tabbycat/adjallocation/consumers.py and 1 other location - About 3 hrs to fix
tabbycat/adjallocation/consumers.py on lines 140..149

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

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