Showing 37 of 54 total issues
File views.py
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
from django.shortcuts import render
from rest_framework.decorators import api_view
from rest_framework.views import APIView
from rest_framework.response import Response
File anomalyDetectionTasks.py
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os
import json
import asyncio
import traceback
import logging
File serializers.py
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
import dateutil.parser as dp
import datetime as dt
from anomaly.settingDetails import settingDicts
from rest_framework import serializers
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
- 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 prepareAnomalyDataframes
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def prepareAnomalyDataframes(
datasetDf, timestampCol, metricCol, dimensionCol=None, operation=None, value=10, nonRollup=False
):
"""
Utility function to prepare anomaly dataframes by grouping on dimension
- 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 addConnection
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def addConnection(payload):
"""
Add connection or build new connection
:param payload: Contains name, connectionType_id, params, description
"""
- 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 anomalyChartToImgStr
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def anomalyChartToImgStr(anomalyId: int = 0):
""" Generate anomaly chart and convert it to image """
anomaly = Anomaly.objects.get(id=anomalyId)
granularity = anomaly.anomalyDefinition.dataset.granularity
data = anomaly.data
Function prophetDetect
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prophetDetect(df, granularity, iterations=None):
"""
Method to perform anomaly detection on given dataframe using fbProphet
"""
today = dt.datetime.now()
Function process_view
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process_view(self, request, view_func, view_args, view_kwargs): # pylint: disable=C0103
"""
Process view method to check login_exempt decorator and enforce authentication on all views
"""
try:
- 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 prophetDetect
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def prophetDetect(df, granularity, iterations=None):
"""
Method to perform anomaly detection on given dataframe using fbProphet
"""
today = dt.datetime.now()
- 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 createRCAAnomaly
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def createRCAAnomaly(
anomalyId: int, dimension: str, dimensionValue: str, contriPercent: float, df
):
"""
Create RCA Anomaly for given anomalyId, dimension, dimensionValue
- 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 prepareAnomalyDataframes
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def prepareAnomalyDataframes(
Function addAnomalyDefinition
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def addAnomalyDefinition(
Function slackAlertHelper
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def slackAlertHelper(title, message, name, details="", anomalyId: int = None):
"""
Helper method for slackAlert
"""
token = ""
- 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 anomalyService
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def anomalyService(dimValObj, dfDict, anomalyDefProps, detectionRuleType, detectionParams):
"""
Method to conduct the anomaly detection process
"""
df = pd.DataFrame(dfDict)
- 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 event_logs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def event_logs(anomalyDef_id,status, publishedCount, totalCount):
"""Event logs on anomaly definition Run"""
userId = "UnIdentified"
try:
# userObject = InstallationTable.objects.all()[0]
- 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 post
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def post(self, request):
"""For new login"""
res = {"message": "Some error occured", "success": False}
if request.method == "POST":
body = json.loads(request.body)
- 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 runQueryOnConnection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def runQueryOnConnection(connectionType, connectionParams, query, limit=True):
dataframe = None
if connectionType == "BigQuery":
params = connectionParams
dataframe = BigQuery.fetchDataframe(params, query, limit=limit)
- 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 detect
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def detect(df, granularity, detectionRuleType, detectionParams, limit=None):
Function minAvgValueOnDimensionalValues
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def minAvgValueOnDimensionalValues(