File models.py
has 401 lines of code (exceeds 250 allowed). Consider refactoring.
import datetime
from typing import TYPE_CHECKING
from django.contrib.auth import get_user_model
from django.db.models import Count, Q, QuerySet
from django.utils import timezone
Function get_resident_percents_by_activity_level_normalized
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
def get_resident_percents_by_activity_level_normalized(self) -> dict[str, float]:
"""Returns the resident counts by activity level annotated with a
percent.
The percent values, when rounded to the nearest integer, should
Cyclomatic complexity is too high in method get_resident_percents_by_activity_level_normalized. (10)
def get_resident_percents_by_activity_level_normalized(self) -> dict[str, float]:
"""Returns the resident counts by activity level annotated with a
percent.
The percent values, when rounded to the nearest integer, should
Cyclomatic complexity is too high in method resident_counts_by_activity_level. (6)
@property
def resident_counts_by_activity_level(self) -> dict[str, int]:
"""Returns a dictionary of counts of residents by activity level."""
annotated_residents = self.residents_with_recent_activity_counts
Cyclomatic complexity is too high in function _structure_resident_data. (6)
def _structure_resident_data(
pivot_result: pd.DataFrame,
current_residents: QuerySet,
date_range: list[datetime.date],
) -> dict:
Avoid deeply nested control flow statements.
if rounded_percents.sum() == 100:
break
keys = [
Function resident_counts_by_activity_level
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def resident_counts_by_activity_level(self) -> dict[str, int]:
"""Returns a dictionary of counts of residents by activity level."""
annotated_residents = self.residents_with_recent_activity_counts
Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed.
def get_resident_percents_by_activity_level_normalized(self) -> dict[str, float]:
There are no issues that match your filters.