cuebook/CueObserve

View on GitHub

Showing 53 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
Severity: Minor
Found in api/anomaly/views.py - About 3 hrs to fix

    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

      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
      Severity: Minor
      Found in api/anomaly/serializers.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

        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
        Severity: Minor
        Found in api/access/utils.py - About 2 hrs to fix

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        Severity: Major
        Found in api/users/migrations/0002_customuser_is_staff.py and 3 other locations - About 2 hrs to fix
        api/anomaly/migrations/0010_runstatus_logs.py on lines 0..16
        api/anomaly/migrations/0018_rootcauseanalysis_taskids.py on lines 0..16
        api/anomaly/migrations/0019_dataset_isnonrollup.py on lines 0..16

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        Severity: Major
        Found in api/anomaly/migrations/0019_dataset_isnonrollup.py and 3 other locations - About 2 hrs to fix
        api/anomaly/migrations/0010_runstatus_logs.py on lines 0..16
        api/anomaly/migrations/0018_rootcauseanalysis_taskids.py on lines 0..16
        api/users/migrations/0002_customuser_is_staff.py on lines 0..16

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        Severity: Major
        Found in api/anomaly/migrations/0010_runstatus_logs.py and 3 other locations - About 2 hrs to fix
        api/anomaly/migrations/0018_rootcauseanalysis_taskids.py on lines 0..16
        api/anomaly/migrations/0019_dataset_isnonrollup.py on lines 0..16
        api/users/migrations/0002_customuser_is_staff.py on lines 0..16

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        Severity: Major
        Found in api/anomaly/migrations/0018_rootcauseanalysis_taskids.py and 3 other locations - About 2 hrs to fix
        api/anomaly/migrations/0010_runstatus_logs.py on lines 0..16
        api/anomaly/migrations/0019_dataset_isnonrollup.py on lines 0..16
        api/users/migrations/0002_customuser_is_staff.py on lines 0..16

        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
        """
        Severity: Minor
        Found in api/anomaly/services/connections.py - About 1 hr to fix

        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
        Severity: Minor
        Found in api/anomaly/services/plotChart.py - About 1 hr to fix

          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()
          Severity: Minor
          Found in api/ops/tasks/detection/core/detectionTypes/prophet.py - About 1 hr to fix

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

            df["ds"] = df["ds"].apply(lambda date: date.isoformat()[:19])
            Severity: Major
            Found in api/ops/tasks/detection/core/detectionTypes/prophet.py and 2 other locations - About 1 hr to fix
            api/ops/tasks/detection/core/detectionTypes/lifetime.py on lines 38..38
            api/ops/tasks/detection/core/detectionTypes/percentageChange.py on lines 33..33

            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:
            Severity: Minor
            Found in api/app/middlewares.py - About 1 hr to fix

            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()
            Severity: Minor
            Found in api/ops/tasks/detection/core/detectionTypes/prophet.py - About 1 hr to fix

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

            df["ds"] = df["ds"].apply(lambda date: date.isoformat()[:19])
            Severity: Major
            Found in api/ops/tasks/detection/core/detectionTypes/lifetime.py and 2 other locations - About 1 hr to fix
            api/ops/tasks/detection/core/detectionTypes/percentageChange.py on lines 33..33
            api/ops/tasks/detection/core/detectionTypes/prophet.py on lines 45..45

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

            df["ds"] = df["ds"].apply(lambda date: date.isoformat()[:19])
            api/ops/tasks/detection/core/detectionTypes/lifetime.py on lines 38..38
            api/ops/tasks/detection/core/detectionTypes/prophet.py on lines 45..45

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            minRow = anomalies[anomalies["y"] == anomalies.y.min()].iloc[-1]
            Severity: Minor
            Found in api/ops/tasks/detection/core/detectionTypes/lifetime.py and 1 other location - About 55 mins to fix
            api/ops/tasks/detection/core/detectionTypes/lifetime.py on lines 15..15

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            migrations.AddField(
            model_name='connectionparam',
            name='connectionType',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='connectionTypeParam', to='anomaly.connectiontype'),
            Severity: Minor
            Found in api/anomaly/migrations/0001_initial.py and 1 other location - About 55 mins to fix
            api/anomaly/migrations/0001_initial.py on lines 67..70

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            def get_metrics(self, obj):
            metrics = json.loads(obj.metrics) if obj.metrics else []
            return metrics if metrics else []
            Severity: Minor
            Found in api/anomaly/serializers.py and 1 other location - About 55 mins to fix
            api/anomaly/serializers.py on lines 126..128
            Severity
            Category
            Status
            Source
            Language