Showing 70 of 194 total issues
Function generateTree
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
File index.tsx
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
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"
File index.tsx
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React, { useRef } from "react"
import styled, { css } from "styled-components"
import {
ContentBlock,
Editor,
Function useReactionLogic
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function useReactionLogic() {
const {
lazyQueryProps: [fetchAllReactions, queryProps],
subscriptionProps,
} = useFetchReactionsAndSubscribeToMore()
Function RedirectUri
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
const RedirectUri = ({ location }: { location: Location }) => {
const { enqueueSnackbar } = useSnackbar()
// `error_description` is generated two ways
// 1. By Cognito
// 2. By my own lambda code
- Read upRead up
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
Open
export const SimpleBottomNavigation = () => {
const { pathname } = useLocation()
const classes = useStyles()
const theme = useTheme()
Function useStyles
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const useStyles = makeStyles((theme) => {
return {
paperRoot: {
background: "var(--geist-background)",
boxShadow: "var(--shadow-medium)",
Function NavBar
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const NavBar = () => {
// const rootPath = `${__PATH_PREFIX__}/`
const { isDarkMode, layoutVersion, postsVersion } = useSelector(
(state: RootState) => ({
Function useCognito
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const useCognito = () => {
const rdxDispatch = useDispatch()
const errorMessage = useSelector(
(state: RootState) => state.cognito?.error?.message
)
Function Bio
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Bio() {
const data = useStaticQuery<Data>(bioQuery)
const { author, social } = data.site.siteMetadata
return (
<div
Function makeUpdatePreferredUsername
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const makeUpdatePreferredUsername = (rdxDispatch: Dispatch) => async (
accessToken: string,
refreshToken: string,
preferredUsername: string,
email: string
Function makeAdminLinkProviderForUser
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const makeAdminLinkProviderForUser = (rdxDispatch: Dispatch) => async (
email: string
) => {
return alert("FIXME")
FB.login(function (response) {
Function uploadAvatar
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const uploadAvatar = async (file: File, imgSrc: string) => {
if (!file) throw new Error("Missing a required 'file' argument")
setIsLoading(true)
try {
Function useOptimisticClaps
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
export const useOptimisticClaps = (
uri: string,
{ remainingClaps = 60 }: Options
) => {
const [queuedClaps, setQueuedClaps] = useState(0)
- Read upRead up
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
Open
function commentsReducer(state: Comment[], action: Action): Comment[] {
switch (action.type) {
case "getAllComments":
return sortByNewest(action.getAllComments)
case "newComment":
Function useFadeGrowEntrance
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const useFadeGrowEntrance = (isIntersecting: boolean) => {
const isDarkMode = useSelector((state) => state.isDarkMode)
const [didIntersect, setDidIntersect] = useState(false)
useEffect(() => {
if (isIntersecting) setDidIntersect(true)
Function FacebookSDK
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const FacebookSDK = memo(() => {
useEffect(() => {
const script: HTMLScriptElement = document.createElement("script")
const appId = process.env.GATSBY_FACEBOOK_APP_ID
script.innerHTML = `
Function GoogleIcon
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const GoogleIcon = () => {
return (
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
Function GoogleSDK
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const GoogleSDK = memo(() => {
useEffect(() => {
const script: HTMLScriptElement = document.createElement("script")
const client_id = process.env.GATSBY_GOOGLE_CLIENT_ID
Function generateUserSkeletons
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function generateUserSkeletons(n: number) {
return (
<>
{Array(n)
.fill(null)