cuebook/CueObserve

View on GitHub
api/ops/tasks/anomalyDetectionTasks.py

Summary

Maintainability
B
6 hrs
Test Coverage
F
31%

File anomalyDetectionTasks.py has 301 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import json
import asyncio
import traceback
import logging
Severity: Minor
Found in api/ops/tasks/anomalyDetectionTasks.py - About 3 hrs to fix

    Function anomalyDetectionJob has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def anomalyDetectionJob(anomalyDef_id: int, manualRun: bool = False):
        """
        Method to find initiate anomaly detection for a given anomaly definition
        :param anomalyDef_id: ID of the anomaly definition
        :param manualRun: Boolean determining whether task was manually initiated
    Severity: Minor
    Found in api/ops/tasks/anomalyDetectionTasks.py - About 2 hrs 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 _anomalyDetectionSubTask has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _anomalyDetectionSubTask(dimValObj, dfDict, anomalyDefProps, detectionRuleType, detectionParams):
    Severity: Minor
    Found in api/ops/tasks/anomalyDetectionTasks.py - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status