TabbycatDebate/tabbycat

tabbycat/draw/generator/powerpair.py

Summary

F
3 days
B
89%

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

``````    def _intermediate_brackets_with_bubble_up_down(self, brackets):
"""Operates in-place.
Requires Team.institution and Team.seen() to be defined."""
self._intermediate_brackets(brackets)  # operates in-place
# Check each of the intermediate brackets for conflicts.``````
Found in tabbycat/draw/generator/powerpair.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"

`PowerPairedDrawGenerator` has 26 functions (exceeds 20 allowed). Consider refactoring. Open

``````class PowerPairedDrawGenerator(BasePairDrawGenerator):
"""Power-paired draw.

If there are allocated sides, use PowerPairedWithAllocatedSidesDrawGenerator
Found in tabbycat/draw/generator/powerpair.py - About 3 hrs to fix

Function `_one_up_one_down` has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring. Open

``````    def _one_up_one_down(self, pairings):
"""We pass the pairings to one_up_one_down.py, then infer annotations
based on the result."""

for bracket in pairings.values():``````
Found in tabbycat/draw/generator/powerpair.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"

Function `_intermediate_brackets_2` has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring. Open

``````    def _intermediate_brackets_2(cls, brackets):
"""Operates in-place.
This implements the second intermediate brackets method, where all debates
in the same intermediate bracket have the same number of wins, but there
might be multiple intermediate brackets between brackets.``````
Found in tabbycat/draw/generator/powerpair.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"

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

``````    def _pullup(self, brackets, indices):
"""'brackets' is what is returned by _make_raw_brackets().
'pos' is a function taking the number of teams to choose from
and number of teams required, and returning a list of indices
for which teams to take as the pullup.``````
Found in tabbycat/draw/generator/powerpair.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"

Function `_intermediate_brackets_1` has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring. Open

``````    def _intermediate_brackets_1(cls, brackets):
"""Operates in-place.
This implements the first intermediate brackets method, where there is at most
one intermediate bracket between brackets, but may have pullups from multiple
brackets.``````
Found in tabbycat/draw/generator/powerpair.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"

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

``````                elif unfilled_pool["neg"]:
# Take the top teams from affirmative pool as appropriate.
num_teams = min(len(unfilled_pool["neg"]), len(pool["aff"]))
intermediates[unfilled_points].append({
"aff": pool["aff"][:num_teams],``````
Found in tabbycat/draw/generator/powerpair.py and 1 other location - About 5 hrs to fix
tabbycat/draw/generator/powerpair.py on lines 598..607

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

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

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

``````                elif unfilled_pool["aff"]:
# In a new bracket, take the lesser of how many excess affirmative
# teams there are, and how many negative teams in the pool we have.
num_teams = min(len(unfilled_pool["aff"]), len(pool["neg"]))
intermediates[unfilled_points].append({``````
Found in tabbycat/draw/generator/powerpair.py and 1 other location - About 5 hrs to fix
tabbycat/draw/generator/powerpair.py on lines 608..616

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

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

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

``````        for points, teams in brackets.items():
bracket = list()
top, bottom = subpool_func(teams)
for teams in zip(top, bottom):
pairing = Pairing(teams=teams, bracket=points, room_rank=i)``````
Found in tabbycat/draw/generator/powerpair.py and 1 other location - About 2 hrs to fix
tabbycat/draw/generator/powerpair.py on lines 295..302

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

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

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

``````        for (points, teams), subpool_func in zip(brackets.items(), subpool_funcs):
bracket = list()
top, bottom = subpool_func(teams)
for teams in zip(top, bottom):
pairing = Pairing(teams=teams, bracket=points, room_rank=i)``````
Found in tabbycat/draw/generator/powerpair.py and 1 other location - About 2 hrs to fix
tabbycat/draw/generator/powerpair.py on lines 280..287

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

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