idlesign/django-oauthost

View on GitHub
oauthost/models.py

Summary

Maintainability
B
5 hrs
Test Coverage

File models.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from uuid import uuid4
from random import randrange

from django.conf import settings
from django.db import models, IntegrityError
Severity: Minor
Found in oauthost/models.py - About 2 hrs to fix

    Function save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self, force_insert=False, force_update=False, **kwargs):
            if not self.code:
                while True:
                    self.code = self.generate_code()
                    try:
    Severity: Minor
    Found in oauthost/models.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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self, force_insert=False, force_update=False, **kwargs):
            if not self.access_token:
                while True:
                    self.access_token = self.generate_token()
                    self.refresh_token = self.generate_token()
    Severity: Minor
    Found in oauthost/models.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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self, force_insert=False, force_update=False, **kwargs):
    
            if not self.identifier:
    
                while True:
    Severity: Minor
    Found in oauthost/models.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

    There are no issues that match your filters.

    Category
    Status