thiskevinwang/coffee-code-climb

View on GitHub

Showing 194 of 194 total issues

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

  const UserTooltip = () => (
    <Box p="var(--geist-gap-half)">
      <Avatar src={avatar_url} />
      <Box flexDirection="row">
        <h3>{name}</h3>
Severity: Major
Found in src/components/MapIdToUser/index.tsx and 1 other location - About 4 hrs to fix
src/components/MapIdToUser/index.tsx on lines 25..34

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 116.

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

Function AttackAnimationSimulator has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function AttackAnimationSimulator(props: PageProps) {
  const { data } = props
  const siteTitle = data.site.siteMetadata.title

  const isDarkMode = useSelector((state) => state.isDarkMode)
Severity: Major
Found in src/pages/attack-animation-simulator.tsx - About 4 hrs to fix

    File useCognito.ts has 332 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { useCallback } from "react"
    import { useDispatch, useSelector } from "react-redux"
    import _ from "lodash"
    import type { CognitoIdentityServiceProvider } from "aws-sdk"
    import type { Dispatch } from "redux"
    Severity: Minor
    Found in src/utils/Playground/useCognito.ts - About 4 hrs to fix

      Function verifyAsync has 94 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const verifyAsync = async () => {
            if (!accessToken) {
              setIsLoggedIn(false)
              return
            }
      Severity: Major
      Found in src/utils/useVerifyTokenSet.ts - About 3 hrs to fix

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

          useEffect(() => {
            const script: HTMLScriptElement = document.createElement("script")
            const client_id = process.env.GATSBY_GOOGLE_CLIENT_ID
        
            script.innerHTML = `
        Severity: Major
        Found in src/components/GoogleSDK.tsx and 1 other location - About 3 hrs to fix
        src/components/FacebookSDK.tsx on lines 13..31

        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 108.

        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 2 locations. Consider refactoring.
        Open

          useEffect(() => {
            const script: HTMLScriptElement = document.createElement("script")
            const appId = process.env.GATSBY_FACEBOOK_APP_ID
            script.innerHTML = `
              window.fbAsyncInit = function() {
        Severity: Major
        Found in src/components/FacebookSDK.tsx and 1 other location - About 3 hrs to fix
        src/components/GoogleSDK.tsx on lines 10..28

        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 108.

        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 2 locations. Consider refactoring.
        Open

          useEffect(() => {
            if (!subscriptionProps.loading && !subscriptionProps.error) {
              const newReaction: Reaction = subscriptionProps.data.newReaction
              if (newReaction) {
                dispatch({
        Severity: Major
        Found in src/hooks/rds/useReactionLogic.ts and 1 other location - About 3 hrs to fix
        src/hooks/rds/useCommentLogic.ts on lines 110..121

        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 105.

        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 2 locations. Consider refactoring.
        Open

          useEffect(() => {
            if (!newCommentSubscription.loading && !newCommentSubscription.error) {
              const newComment: Comment = newCommentSubscription.data.newComment
              if (newComment) {
                dispatch({
        Severity: Major
        Found in src/hooks/rds/useCommentLogic.ts and 1 other location - About 3 hrs to fix
        src/hooks/rds/useReactionLogic.ts on lines 57..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 105.

        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

        File NavBar2.tsx has 312 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

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

          Function PostsManager has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          const PostsManager = ({ allPosts, location }: PostsManagerProps) => {
            const postsVersion = useSelector((state) => state.postsVersion)
            const posts = useMemo(() => generatePosts(allPosts), [allPosts])
          
            const [items, setItems] = useState(() => posts)
          Severity: Minor
          Found in src/components/PostsManager/PostsManager.tsx - About 3 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

          File PostsManager.tsx has 296 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React, { useState, useEffect, useCallback, useMemo } from "react"
          import { PageProps } from "gatsby"
          import { useSelector } from "react-redux"
          import _ from "lodash"
          import styled from "styled-components"
          Severity: Minor
          Found in src/components/PostsManager/PostsManager.tsx - About 3 hrs to fix

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

                            {location.state?.isError && (
                              <Box mb={2}>
                                <Alert
                                  severity="error"
                                  variant="standard"
            Severity: Major
            Found in src/pages/auth/login.tsx and 1 other location - About 2 hrs to fix
            src/pages/auth/login.tsx on lines 106..116

            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 94.

            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 2 locations. Consider refactoring.
            Open

                            {location.state?.isSuccess && (
                              <Box mb={3}>
                                <Alert
                                  severity="success"
                                  variant="standard"
            Severity: Major
            Found in src/pages/auth/login.tsx and 1 other location - About 2 hrs to fix
            src/pages/auth/login.tsx on lines 117..127

            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 94.

            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 2 locations. Consider refactoring.
            Open

                  <Box mx={1} my={"auto"}>
                    <Button onClick={dispatchSetLayoutVersion((layoutVersion % 2) + 1)}>
                      <span>{`Layout: `}</span>
                      <label>V{layoutVersion}</label>
                    </Button>
            Severity: Major
            Found in src/components/NavBar/index.tsx and 1 other location - About 2 hrs to fix
            src/components/NavBar/index.tsx on lines 76..81

            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 94.

            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 2 locations. Consider refactoring.
            Open

                  <Box mx={1} my={"auto"}>
                    <Button onClick={dispatchSetPostsVersion((postsVersion % 2) + 1)}>
                      <span>{`Posts: `}</span>
                      <label>V{postsVersion}</label>
                    </Button>
            Severity: Major
            Found in src/components/NavBar/index.tsx and 1 other location - About 2 hrs to fix
            src/components/NavBar/index.tsx on lines 70..75

            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 94.

            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

            File app.tsx has 287 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, { useEffect } from "react"
            import ms from "ms"
            import { useLazyQuery, gql } from "@apollo/client"
            import { navigate, PageProps, Link } from "gatsby"
            import { Router } from "@reach/router"
            Severity: Minor
            Found in src/pages/app.tsx - About 2 hrs to fix

              Function overrideThemeStyles has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Wordpress2016.overrideThemeStyles = (a, b) => {
                // console.log("a", a, "b", b)
                return {
                  "a.gatsby-resp-image-link": {
                    boxShadow: `none`,
              Severity: Major
              Found in src/utils/typography/index.tsx - About 2 hrs to fix

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

                          validate={({ email }) => {
                            const errors: FormikErrors<Values> = {}
                            if (!email) {
                              errors.email = "Required"
                            } else if (
                Severity: Major
                Found in src/pages/auth/signup.tsx and 2 other locations - About 2 hrs to fix
                src/pages/auth/login.tsx on lines 63..73
                src/pages/auth/verify.tsx on lines 67..75

                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 91.

                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

                Function Discussions has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const Discussions = (props: RouteComponentProps) => {
                  const { data, fetchMore } = useQuery<{
                    getDiscussions: Query["getDiscussions"]
                  }>(GET_DISCUSSIONS_QUERY)
                
                
                Severity: Major
                Found in src/components/App/Discussions.tsx - About 2 hrs to fix

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

                            validate={({ code }) => {
                              const errors: FormikErrors<Values> = {}
                              if (!code) {
                                errors.code = "Required"
                              } else if (!/^[0-9]{6}$/i.test(code)) {
                  Severity: Major
                  Found in src/pages/auth/verify.tsx and 2 other locations - About 2 hrs to fix
                  src/pages/auth/login.tsx on lines 63..73
                  src/pages/auth/signup.tsx on lines 49..59

                  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 91.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language