GregBrimble/cf-workers-dashboard

View on GitHub

Showing 21 of 91 total issues

File dataCenters.ts has 1458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export const dataCenters = [
  {
    group: "Africa",
    name: "Antananarivo, Madagascar",
    id: "TNR",
Severity: Major
Found in packages/server/src/lib/dataCenters.ts - About 3 days to fix

    Function Home has 405 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const Home = () => {
      const { hasToken, hasKey } = useSettings();
    
      if (hasKey || hasToken) return <Redirect to="/accounts" />;
    
    
    Severity: Major
    Found in packages/client/src/pages/Home.tsx - About 2 days to fix

      Function Settings has 302 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const Settings = forwardRef((props, ref) => {
        const homeMatch = useRouteMatch({
          path: "/",
          exact: true,
        }) as Record<string, any>;
      Severity: Major
      Found in packages/client/src/components/Settings.tsx - About 1 day to fix

        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

          Function Container has 247 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const Container = () => {
            const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
            const [profileDropdownOpen, setProfileDropdownOpen] = useState(false);
            const location = useLocation();
          
          
          Severity: Major
          Found in packages/client/src/pages/Container.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

              File Home.tsx has 413 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React from "react";
              import { Link, Redirect } from "react-router-dom";
              import { ExampleEditor } from "../components/home/ExampleEditor";
              import { ExampleAnalytics } from "../components/home/ExampleAnalytics";
              import { ExamplePeek } from "../components/home/ExamplePeek";
              Severity: Minor
              Found in packages/client/src/pages/Home.tsx - About 5 hrs to fix

                Function Worker has 146 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const Worker: FC = () => {
                  const { workerID: scriptID, accountID } = useParams();
                  const { path, url } = useRouteMatch();
                  const history = useHistory();
                  const location = useLocation();
                Severity: Major
                Found in packages/client/src/pages/Worker.tsx - About 5 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

                    File analytics.ts has 358 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import gql from "graphql-tag";
                    import {
                      GraphQLResolveInfo,
                      DocumentNode,
                      FieldNode,
                    Severity: Minor
                    Found in packages/server/src/graphql/schema/analytics.ts - About 4 hrs to fix

                      Function Workers has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const Workers: FC<{}> = ({}) => {
                        const { url } = useRouteMatch();
                        const { accountID } = useParams();
                        const { loading, error, data } = useQuery(WORKERS_QUERY, {
                          variables: { accountID },
                      Severity: Major
                      Found in packages/client/src/pages/Workers.tsx - About 3 hrs to fix

                        File Settings.tsx has 318 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import React, {
                          useState,
                          forwardRef,
                          useImperativeHandle,
                          createRef,
                        Severity: Minor
                        Found in packages/client/src/components/Settings.tsx - About 3 hrs to fix

                          File ExamplePeek.tsx has 284 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import React, { useEffect, useState, useReducer } from "react";
                          import Plot from "react-plotly.js";
                          
                          type Location = {
                            location: string;
                          Severity: Minor
                          Found in packages/client/src/components/home/ExamplePeek.tsx - About 2 hrs to fix

                            File Container.tsx has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import React, { useState, useEffect, useRef, createRef } from "react";
                            import { Transition } from "../components/lib/Transition";
                            import { useWindowKey } from "../hooks/useWindowKey";
                            import { classNames } from "../utils/classNames";
                            import { useMouseOutside } from "../hooks/useMouseOutside";
                            Severity: Minor
                            Found in packages/client/src/pages/Container.tsx - About 2 hrs to fix

                              Function Accounts has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const Accounts: FC<{}> = ({}) => {
                                const { url } = useRouteMatch();
                                const { state: { autoSelect } = { autoSelect: false } } = useLocation();
                                const { loading, error, data } = useQuery(ACCOUNTS_QUERY);
                              
                              
                              Severity: Major
                              Found in packages/client/src/pages/Accounts.tsx - About 2 hrs to fix

                                Function handleRequest has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export const handleRequest = async (request: Request) => {
                                  const data = await request.formData();
                                  const socketID = data.get("socket_id").toString();
                                  const channelName = data.get("channel_name").toString();
                                
                                
                                Severity: Minor
                                Found in packages/server/src/pusher/auth.ts - About 1 hr to fix

                                  Function handleRequest has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const handleRequest = async (request: Request): Promise<Response> => {
                                    let graphQLRequest: GraphQLRequest;
                                  
                                    try {
                                      switch (request.method.toLowerCase()) {
                                  Severity: Minor
                                  Found in packages/server/src/graphql/index.ts - About 1 hr to fix

                                    Function Cell has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    }> = ({ path, state: { data }, dispatch, value }) => {
                                      let hint;
                                      let disabled = false;
                                      const type = typeof value;
                                      if (["string", "number", "bigint"].includes(type)) return value;
                                    Severity: Minor
                                    Found in packages/client/src/components/MagicTable/Cell.tsx - 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 Table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    }> = ({ state, dispatch, header = (accessor) => accessor }) => {
                                      const { data, isArray } = useMemo(() => {
                                        const { pathStack, data } = state;
                                        const path = last(pathStack);
                                        const currentData = path ? get(data, path) : data;
                                    Severity: Minor
                                    Found in packages/client/src/components/MagicTable/Table.tsx - 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

                                    Avoid too many return statements within this function.
                                    Open

                                      return (
                                        <div>
                                          <a
                                            href="#"
                                            className={classNames(
                                    Severity: Major
                                    Found in packages/client/src/components/MagicTable/Cell.tsx - About 30 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language