Terralego/django-terra-settings

View on GitHub

Showing 3 of 3 total issues

Function get_media_response has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_media_response(request, data, permissions=None, headers=None):
    # For compatibility purpose
    content, url = None, None
    if isinstance(data, (File, )):
        content, url = data, data.url
Severity: Minor
Found in terra_settings/helpers/responses.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 validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs):
        if attrs.get('base_layer_type') == 'mapbox':
            if attrs.get('tiles'):
                raise ValidationError(_("'tiles' should not be filled for mapbox base layers."))
            if not attrs.get('map_box_url'):
Severity: Minor
Found in terra_settings/base_layers/serializers.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(self, *args, **options):
        self.test_mode = True if options.get('test_data') else False

        if options.get('list', False):
            self.stdout.write('Applications with populate modules:')
Severity: Minor
Found in terra_settings/management/commands/populatedata.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

Severity
Category
Status
Source
Language