GregBrimble/cf-workers-dashboard

View on GitHub
packages/client/src/components/workers/Analytics.tsx

Summary

Maintainability
F
4 days
Test Coverage

Function Analytics has 286 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const Analytics = () => {
  const { workerID: scriptID, accountID } = useParams();

  const now = new Date();
  const defaultDateFrom = new Date(now);
Severity: Major
Found in packages/client/src/components/workers/Analytics.tsx - About 1 day to fix

    File Analytics.tsx has 436 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useState } from "react";
    import Plot from "react-plotly.js";
    import { BigStatus } from "../BigStatus";
    import { useQuery, gql } from "@apollo/client";
    import { useParams } from "react-router-dom";
    Severity: Minor
    Found in packages/client/src/components/workers/Analytics.tsx - About 6 hrs to fix

      Function analyticsToSeries has 131 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const analyticsToSeries = (analytics: any, interval: string) => {
        const min = {
          x: [] as Date[],
          y: [] as number[],
          type: "scatter",
      Severity: Major
      Found in packages/client/src/components/workers/Analytics.tsx - About 5 hrs to fix

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

          const p90 = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "p90",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 13..20
        packages/client/src/components/workers/Analytics.tsx on lines 21..28
        packages/client/src/components/workers/Analytics.tsx on lines 29..36
        packages/client/src/components/workers/Analytics.tsx on lines 37..44
        packages/client/src/components/workers/Analytics.tsx on lines 53..60
        packages/client/src/components/workers/Analytics.tsx on lines 61..68
        packages/client/src/components/workers/Analytics.tsx on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const min = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "min",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 21..28
        packages/client/src/components/workers/Analytics.tsx on lines 29..36
        packages/client/src/components/workers/Analytics.tsx on lines 37..44
        packages/client/src/components/workers/Analytics.tsx on lines 45..52
        packages/client/src/components/workers/Analytics.tsx on lines 53..60
        packages/client/src/components/workers/Analytics.tsx on lines 61..68
        packages/client/src/components/workers/Analytics.tsx on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const p25 = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "p25",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 13..20
        packages/client/src/components/workers/Analytics.tsx on lines 29..36
        packages/client/src/components/workers/Analytics.tsx on lines 37..44
        packages/client/src/components/workers/Analytics.tsx on lines 45..52
        packages/client/src/components/workers/Analytics.tsx on lines 53..60
        packages/client/src/components/workers/Analytics.tsx on lines 61..68
        packages/client/src/components/workers/Analytics.tsx on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const p75 = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "p75",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 13..20
        packages/client/src/components/workers/Analytics.tsx on lines 21..28
        packages/client/src/components/workers/Analytics.tsx on lines 29..36
        packages/client/src/components/workers/Analytics.tsx on lines 45..52
        packages/client/src/components/workers/Analytics.tsx on lines 53..60
        packages/client/src/components/workers/Analytics.tsx on lines 61..68
        packages/client/src/components/workers/Analytics.tsx on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const p50 = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "p50",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 13..20
        packages/client/src/components/workers/Analytics.tsx on lines 21..28
        packages/client/src/components/workers/Analytics.tsx on lines 37..44
        packages/client/src/components/workers/Analytics.tsx on lines 45..52
        packages/client/src/components/workers/Analytics.tsx on lines 53..60
        packages/client/src/components/workers/Analytics.tsx on lines 61..68
        packages/client/src/components/workers/Analytics.tsx on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const max = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "max",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 13..20
        packages/client/src/components/workers/Analytics.tsx on lines 21..28
        packages/client/src/components/workers/Analytics.tsx on lines 29..36
        packages/client/src/components/workers/Analytics.tsx on lines 37..44
        packages/client/src/components/workers/Analytics.tsx on lines 45..52
        packages/client/src/components/workers/Analytics.tsx on lines 53..60
        packages/client/src/components/workers/Analytics.tsx on lines 61..68

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const p99 = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "p99",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 13..20
        packages/client/src/components/workers/Analytics.tsx on lines 21..28
        packages/client/src/components/workers/Analytics.tsx on lines 29..36
        packages/client/src/components/workers/Analytics.tsx on lines 37..44
        packages/client/src/components/workers/Analytics.tsx on lines 45..52
        packages/client/src/components/workers/Analytics.tsx on lines 61..68
        packages/client/src/components/workers/Analytics.tsx on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const p999 = {
            x: [] as Date[],
            y: [] as number[],
            type: "scatter",
            name: "p999",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 7 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 13..20
        packages/client/src/components/workers/Analytics.tsx on lines 21..28
        packages/client/src/components/workers/Analytics.tsx on lines 29..36
        packages/client/src/components/workers/Analytics.tsx on lines 37..44
        packages/client/src/components/workers/Analytics.tsx on lines 45..52
        packages/client/src/components/workers/Analytics.tsx on lines 53..60
        packages/client/src/components/workers/Analytics.tsx on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const requests = {
            x: [] as Date[],
            y: [] as number[],
            type: "bar",
            yaxis: "y2",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 2 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 77..86
        packages/client/src/components/workers/Analytics.tsx on lines 97..106

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 60.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const subrequests = {
            x: [] as Date[],
            y: [] as number[],
            type: "bar",
            yaxis: "y2",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 2 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 77..86
        packages/client/src/components/workers/Analytics.tsx on lines 87..96

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 60.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          const errors = {
            x: [] as Date[],
            y: [] as number[],
            type: "bar",
            yaxis: "y2",
        Severity: Major
        Found in packages/client/src/components/workers/Analytics.tsx and 2 other locations - About 1 hr to fix
        packages/client/src/components/workers/Analytics.tsx on lines 87..96
        packages/client/src/components/workers/Analytics.tsx on lines 97..106

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 60.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        There are no issues that match your filters.

        Category
        Status