aw_server/api.py
File api.py
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import functools
import json
import logging
from datetime import datetime
from pathlib import Path
ServerAPI
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class ServerAPI:
def __init__(self, db, testing) -> None:
self.db = db
self.settings = Settings(testing)
self.testing = testing
Function heartbeat
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def heartbeat(self, bucket_id: str, heartbeat: Event, pulsetime: float) -> Event:
"""
Heartbeats are useful when implementing watchers that simply keep
track of a state, how long it's in that state and when it changes.
A single heartbeat always has a duration of zero.
- Read upRead up
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 create_bucket
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def create_bucket(
Function update_bucket
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def update_bucket(