svthalia/concrexit

View on GitHub
website/events/models/event.py

Summary

Maintainability
C
1 day
Test Coverage

File event.py has 624 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import uuid

from django.conf import settings
from django.core import validators
from django.core.exceptions import ObjectDoesNotExist, ValidationError
Severity: Major
Found in website/events/models/event.py - About 1 day to fix

Function clean has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    def clean(self):
        super().clean()
        errors = {}
        if self.start is None:
            errors.update({"start": _("Start cannot have an empty date or time field")})
Severity: Minor
Found in website/events/models/event.py - About 7 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

Event has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class Event(models.Model):
    """Describes an event."""

    objects = QueryablePropertiesManager()

Severity: Minor
Found in website/events/models/event.py - About 2 hrs to fix

Function clean_changes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def clean_changes(self, changed_data):
        """Check if changes from `changed_data` are allowed.

        This method should be run from a form clean() method, where changed_data
        can be retrieved from self.changed_data
Severity: Minor
Found in website/events/models/event.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

There are no issues that match your filters.

Category
Status