svthalia/concrexit

View on GitHub
website/members/models/profile.py

Summary

Maintainability
B
6 hrs
Test Coverage

File profile.py has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging

from django.conf import settings
from django.core import validators
from django.core.exceptions import ValidationError
Severity: Minor
Found in website/members/models/profile.py - About 3 hrs to fix

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

    def display_name(self):
        pref = self.display_name_preference
        if pref == "nickname" and self.nickname is not None:
            return f"'{self.nickname}'"
        if pref == "firstname":
Severity: Minor
Found in website/members/models/profile.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 clean has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def clean(self):
        super().clean()
        errors = {}

        if not self.is_minimized and not (
Severity: Minor
Found in website/members/models/profile.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

Avoid too many return statements within this function.
Open

            return f"{self.user.first_name} '{self.nickname}' {self.user.last_name}"
Severity: Major
Found in website/members/models/profile.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return self.user.get_full_name() or self.user.username
Severity: Major
Found in website/members/models/profile.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return f"'{self.nickname}' {self.user.last_name}"
Severity: Major
Found in website/members/models/profile.py - About 30 mins to fix

There are no issues that match your filters.

Category
Status