TabbycatDebate/tabbycat

View on GitHub

Showing 446 of 446 total issues

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

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

    def __init__(self, container, chair=None, panellists=None, trainees=None, from_db=False):
        """The `container` is a model instance that relates to adjudicators via
        a RelatedManager. It's easiest to think of this as a "panel", though the
        typical use case is actually a debate. The model instance's model class
        must define a property `related_adjudicator_set`, which must be the
Severity: Minor
Found in tabbycat/adjallocation/allocation.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

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

        if auto_create_categories:
            def venue_category_interpreter(lineno, line):
                if not line.get('category'):
                    return None
                return {'name': line['category']}
Severity: Major
Found in tabbycat/importer/importers/boots.py and 1 other location - About 1 hr to fix
tabbycat/importer/importers/anorak.py on lines 103..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 58.

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 auto_create_regions:
            def region_interpreter(lineno, line):
                if not line.get('region'):
                    return None
                return {
Severity: Major
Found in tabbycat/importer/importers/anorak.py and 1 other location - About 1 hr to fix
tabbycat/importer/importers/boots.py on lines 213..218

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

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 get_context_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_context_data(self, **kwargs):
        t = self.tournament
        adjudicators = self.get_adjudicators()
        weight = t.current_round.feedback_weight
        scores = [a.weighted_score(weight) for a in adjudicators]
Severity: Minor
Found in tabbycat/adjfeedback/views.py - About 1 hr to fix

    Function handle_tournament has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def handle_tournament(self, tournament, **options):
            for team in tournament.team_set.all():
                if team.reference.startswith(team.institution.code + " "):
                    new_reference = team.reference[len(team.institution.code):].strip()
                    self.stdout.write("{verb} team {!r} from {} to {!r}".format(
    Severity: Minor
    Found in tabbycat/participants/management/commands/convertteamnames.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 populate_objects has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def populate_objects(self, prefill=True):
            self.object = self.get_object() # must be populated before self.error_page() called
    
            if self.round.draw_status != Round.Status.RELEASED:
                return self.error_page(_("The draw for this round hasn't been released yet."))
    Severity: Minor
    Found in tabbycat/results/views.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 merge_speaker_result has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def merge_speaker_result(self, result: BaseDebateResult) -> list[ResultError]:
            errors = self.merge_speaker_order(result)
            for side, pos in product(self.sides, self.positions):
                for criterion in self.criteria:
                    if self.get_criterion_score(side, pos, criterion) is None:
    Severity: Minor
    Found in tabbycat/results/result.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 import_speakers has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def import_speakers(self, f, auto_create_teams=True):
            """Imports speakers, also creating teams as needed (unless
            'auto_create_teams' is False). Institutions are not created as needed;
            if an institution doesn't exist, an error is raised.
            """
    Severity: Minor
    Found in tabbycat/importer/importers/anorak.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 get_url_args has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

    def get_url_args(parser, token):
        """Helper function, returns the arguments necessary to construct a URL node.
        This code is copied directly from `url` in django/template/defaulttags.py,
        except that instead of constructing a URL node with the identified
        parameters, it simply returns the parameters in a tuple.
    Severity: Minor
    Found in tabbycat/utils/templatetags/debate_tags.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

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

            if self.no_trainees:
                trainees = []
            else:
                trainees = [a for a in self.adjudicators if a not in voting]
                trainees.sort(key=lambda a: a._normalized_score, reverse=True)
    Severity: Major
    Found in tabbycat/adjallocation/allocators/hungarian.py and 1 other location - About 1 hr to fix
    tabbycat/adjallocation/allocators/hungarian.py on lines 263..267

    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

    Function get_feedbacks has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def get_feedbacks(self):
            feedbacks = self.get_feedback_queryset()
    
            populate_debate_adjudicators(feedbacks)
            populate_wins_for_debateteams([f.source_team for f in feedbacks if f.source_team is not None])
    Severity: Minor
    Found in tabbycat/adjfeedback/views.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 has_permission has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

    def has_permission(user: 'settings.AUTH_USER_MODEL', permission: permission_type, tournament: 'Tournament') -> bool:
        if user.is_anonymous:
            return False
        if user.is_superuser:
            return True
    Severity: Minor
    Found in tabbycat/users/permissions.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 add_draw_conflicts_columns has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def add_draw_conflicts_columns(self, debates, venue_conflicts, adjudicator_conflicts):
    
            conflicts_by_debate = []
            for debate in debates:
                # conflicts is a list of (level, message) tuples
    Severity: Minor
    Found in tabbycat/utils/tables.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 handle_round has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def handle_round(self, round, **options):
            panels = round.preformedpanel_set.all()
            debates = round.debate_set.all()
    
            allocator_class = registry[options["allocator"]]

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

        def get_queryset(self):
            query_params = self.request.query_params
            filters = Q()
    
            # Disallow querying for feedback that they didn't submit
    Severity: Minor
    Found in tabbycat/api/views.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

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

            if self.no_trainees:
                trainees = []
            else:
                trainees = [a for a in self.adjudicators if a not in voting]
                trainees.sort(key=lambda a: a._normalized_score, reverse=True)
    Severity: Major
    Found in tabbycat/adjallocation/allocators/hungarian.py and 1 other location - About 1 hr to fix
    tabbycat/adjallocation/allocators/hungarian.py on lines 151..155

    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

    Function add_metric_columns has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def add_metric_columns(self, standings, integer_score_columns=[]):
            """`integer_score_columns`, if given, indicates which metrics to cast to
            an int if the metric's value is an integer. For example, if the
            tournament preferences are such that the total speaker score should
            always be an integer, a list containing the string 'total' or
    Severity: Minor
    Found in tabbycat/utils/tables.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 generate has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
    Open

        def generate(cls, to: 'QuerySet[Person]', url: str, round: 'Round') -> List[Tuple[EmailContextData, 'Person']]:
            emails = []
            to_ids = {p.id for p in to}
            draw = round.debate_set_with_prefetches(speakers=False).filter(debateadjudicator__adjudicator__in=to)
            use_codes = use_team_code_names(round.tournament, False)
    Severity: Minor
    Found in tabbycat/notifications/utils.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

    Severity
    Category
    Status
    Source
    Language