TabbycatDebate/tabbycat

View on GitHub
tabbycat/api/serializers.py

Summary

Maintainability
C
1 day
Test Coverage
F
46%

File serializers.py has 873 lines of code (exceeds 600 allowed). Consider refactoring.
Open

from collections import OrderedDict
from collections.abc import Mapping
from urllib import parse

from django.core.exceptions import ValidationError as DjangoValidationError
Severity: Major
Found in tabbycat/api/serializers.py - About 1 day to fix

    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

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

        def validate(self, data):
            source = data.pop('source')
            debate = data.pop('debate')
    
            # Test answers for correct source
    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 create has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
    Open

        def create(self, validated_data):
            result_data = validated_data.pop('result').pop('get_result_info')
            validated_data.update(self.get_submitter_fields())
            if validated_data.get('confirmed', False):
                validated_data['confirmer'] = self.context['request'].user
    Severity: Minor
    Found in tabbycat/api/serializers.py - About 25 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

    There are no issues that match your filters.

    Category
    Status