app/models/user.py
User
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class User(SoftDeletionModel):
"""User model class"""
__tablename__ = 'users'
- Create a ticketCreate a ticket
File user.py
has 392 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import random
from datetime import datetime
import humanize
import pytz
- Create a ticketCreate a ticket
Function _has_perm
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def _has_perm(self, operation, service_class, event_id):
# Operation names and their corresponding permission in `Permissions`
operations = {
'create': 'can_create',
'read': 'can_read',
- Read upRead up
- Create a ticketCreate a ticket
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"