thiskevinwang/coffee-code-climb

View on GitHub

Showing 70 of 194 total issues

Function generateTree has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    (nodes: (ASTNode | LeafNode)[], depth: number = 0): React.ReactNode => {
      return nodes.map((node, i) => {
        if (!node.children) return node.content

        // intercept "<a>" nodes, and create a gatsby Link instead
Severity: Major
Found in src/components/TableOfContents.tsx - About 2 hrs to fix

    File index.tsx has 257 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useState } from "react"
    import { useSelector, useDispatch } from "react-redux"
    import { Link, navigate } from "gatsby"
    import { useApolloClient, gql } from "@apollo/client"
    import { useSnackbar } from "notistack"
    Severity: Minor
    Found in src/components/SwipeableTemporaryDrawer/index.tsx - About 2 hrs to fix

      File index.tsx has 257 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React, { useRef } from "react"
      import styled, { css } from "styled-components"
      import {
        ContentBlock,
        Editor,
      Severity: Minor
      Found in src/components/RichEditor/index.tsx - About 2 hrs to fix

        Function useReactionLogic has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function useReactionLogic() {
          const {
            lazyQueryProps: [fetchAllReactions, queryProps],
            subscriptionProps,
          } = useFetchReactionsAndSubscribeToMore()
        Severity: Major
        Found in src/hooks/rds/useReactionLogic.ts - About 2 hrs to fix

          Function RedirectUri has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          const RedirectUri = ({ location }: { location: Location }) => {
            const { enqueueSnackbar } = useSnackbar()
            // `error_description` is generated two ways
            // 1. By Cognito
            // 2. By my own lambda code
          Severity: Minor
          Found in src/pages/redirect_uri.tsx - 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 SimpleBottomNavigation has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const SimpleBottomNavigation = () => {
            const { pathname } = useLocation()
          
            const classes = useStyles()
            const theme = useTheme()
          Severity: Major
          Found in src/components/SimpleBottomNavigation/index.tsx - About 2 hrs to fix

            Function useStyles has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const useStyles = makeStyles((theme) => {
              return {
                paperRoot: {
                  background: "var(--geist-background)",
                  boxShadow: "var(--shadow-medium)",
            Severity: Minor
            Found in src/pages/app.tsx - About 1 hr to fix

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

              const NavBar = () => {
                // const rootPath = `${__PATH_PREFIX__}/`
              
                const { isDarkMode, layoutVersion, postsVersion } = useSelector(
                  (state: RootState) => ({
              Severity: Minor
              Found in src/components/NavBar/index.tsx - About 1 hr to fix

                Function useCognito has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const useCognito = () => {
                  const rdxDispatch = useDispatch()
                  const errorMessage = useSelector(
                    (state: RootState) => state.cognito?.error?.message
                  )
                Severity: Minor
                Found in src/utils/Playground/useCognito.ts - About 1 hr to fix

                  Function Bio has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function Bio() {
                    const data = useStaticQuery<Data>(bioQuery)
                    const { author, social } = data.site.siteMetadata
                    return (
                      <div
                  Severity: Minor
                  Found in src/components/bio.tsx - About 1 hr to fix

                    Function makeUpdatePreferredUsername has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const makeUpdatePreferredUsername = (rdxDispatch: Dispatch) => async (
                      accessToken: string,
                      refreshToken: string,
                      preferredUsername: string,
                      email: string
                    Severity: Minor
                    Found in src/utils/Playground/useCognito.ts - About 1 hr to fix

                      Function makeAdminLinkProviderForUser has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const makeAdminLinkProviderForUser = (rdxDispatch: Dispatch) => async (
                        email: string
                      ) => {
                        return alert("FIXME")
                        FB.login(function (response) {
                      Severity: Minor
                      Found in src/utils/Playground/useCognito.ts - About 1 hr to fix

                        Function uploadAvatar has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          const uploadAvatar = async (file: File, imgSrc: string) => {
                            if (!file) throw new Error("Missing a required 'file' argument")
                            setIsLoading(true)
                        
                            try {
                        Severity: Minor
                        Found in src/hooks/rds/useUploadAvatar.ts - About 1 hr to fix

                          Function useOptimisticClaps has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export const useOptimisticClaps = (
                            uri: string,
                            { remainingClaps = 60 }: Options
                          ) => {
                            const [queuedClaps, setQueuedClaps] = useState(0)
                          Severity: Minor
                          Found in src/hooks/useOptimisticClaps.ts - About 1 hr 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 commentsReducer has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function commentsReducer(state: Comment[], action: Action): Comment[] {
                            switch (action.type) {
                              case "getAllComments":
                                return sortByNewest(action.getAllComments)
                              case "newComment":
                          Severity: Minor
                          Found in src/hooks/rds/useCommentLogic.ts - About 1 hr to fix

                            Function useFadeGrowEntrance has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const useFadeGrowEntrance = (isIntersecting: boolean) => {
                              const isDarkMode = useSelector((state) => state.isDarkMode)
                              const [didIntersect, setDidIntersect] = useState(false)
                              useEffect(() => {
                                if (isIntersecting) setDidIntersect(true)
                            Severity: Minor
                            Found in src/components/Posts/V2.tsx - About 1 hr to fix

                              Function FacebookSDK has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const FacebookSDK = memo(() => {
                                useEffect(() => {
                                  const script: HTMLScriptElement = document.createElement("script")
                                  const appId = process.env.GATSBY_FACEBOOK_APP_ID
                                  script.innerHTML = `
                              Severity: Minor
                              Found in src/components/FacebookSDK.tsx - About 1 hr to fix

                                Function GoogleIcon has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export const GoogleIcon = () => {
                                  return (
                                    <svg
                                      version="1.1"
                                      xmlns="http://www.w3.org/2000/svg"
                                Severity: Minor
                                Found in src/icons/google-icon.tsx - About 1 hr to fix

                                  Function GoogleSDK has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const GoogleSDK = memo(() => {
                                    useEffect(() => {
                                      const script: HTMLScriptElement = document.createElement("script")
                                      const client_id = process.env.GATSBY_GOOGLE_CLIENT_ID
                                  
                                  
                                  Severity: Minor
                                  Found in src/components/GoogleSDK.tsx - About 1 hr to fix

                                    Function generateUserSkeletons has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    function generateUserSkeletons(n: number) {
                                      return (
                                        <>
                                          {Array(n)
                                            .fill(null)
                                    Severity: Minor
                                    Found in src/components/App/Profile.tsx - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language