flamingo-run/django-cloud-tasks

View on GitHub
django_cloud_tasks/tasks/task.py

Summary

Maintainability
B
6 hrs
Test Coverage

File task.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import abc
import inspect
from dataclasses import dataclass, fields
from datetime import datetime, timedelta, timezone
from functools import lru_cache
Severity: Minor
Found in django_cloud_tasks/tasks/task.py - About 3 hrs to fix

    Function from_headers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_headers(cls, headers: dict) -> Self:
            # Available data: https://cloud.google.com/tasks/docs/creating-http-target-tasks#handler
            cloud_tasks_prefix = "X-Cloudtasks-"
            cloud_scheduler_prefix = "X-Cloudscheduler"
    
    
    Severity: Minor
    Found in django_cloud_tasks/tasks/task.py - About 1 hr 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 discard has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def discard(cls, task_id: str | None = None, min_retries: int = 0):
            client = cls._get_tasks_client()
            if task_id:
                task_objects = [client.get_task(queue_name=cls.queue(), task_name=task_id)]
            else:
    Severity: Minor
    Found in django_cloud_tasks/tasks/task.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 push has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def push(
            cls,
            task_kwargs: dict,
            headers: dict | None = None,
            queue: str | None = None,
    Severity: Minor
    Found in django_cloud_tasks/tasks/task.py - About 35 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 __eq__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other) -> bool:
            if not isinstance(other, TaskMetadata):
                return False
    
            check_fields = [field.name for field in fields(TaskMetadata)]
    Severity: Minor
    Found in django_cloud_tasks/tasks/task.py - About 25 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