xylabs/sdk-react

View on GitHub

Showing 48 of 179 total issues

Function usePromise has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const usePromise = <TResult>(
  promise: () => Promise<TResult | undefined>,
  dependencies: DependencyList,
  config?: UsePromiseConfig<TResult>,
): [TResult | undefined, Error | undefined, UsePromiseState | undefined] => {
Severity: Minor
Found in packages/promise/src/usePromise.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 InvertibleThemeProvider has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const InvertibleThemeProvider: React.FC<InvertibleThemeProviderProps> = ({
  options,
  children,
  dark,
  resolve = false,
Severity: Minor
Found in packages/invertible-theme/src/InvertibleThemeProvider.tsx - 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 BasePage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const BasePage: React.FC<BasePageProps> = ({
  disableGutters,
  children,
  beta,
  container,
Severity: Minor
Found in packages/base-page/src/components/BasePage/BasePage.tsx - 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 Experiments has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Experiments: React.FC<ExperimentsProps> = (props) => {
  const {
    name, children, localStorageProp = true,
  } = props
  const userEvents = useUserEvents()
Severity: Minor
Found in packages/experiments/src/components/Experiments.tsx - About 1 hr to fix

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

    export const useNavigateToEthAddress = () => {
      const navigate = useNavigate()
      const navigateToEthAddress = (
        address: EthAddress,
        event: React.MouseEvent,
    Severity: Minor
    Found in packages/crypto/src/hooks/useNavigateToEthAddress.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 CookieConsentBody has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export const CookieConsentBody: React.FC<CookieConsentProps> = ({
      acceptOnScroll, acceptOnTimer = 0, onAccept, ...props
    }) => {
      const {
        accepted, setAccepted, storageName,
    Severity: Minor
    Found in packages/cookie-consent/src/components/CookieConsentBody.tsx - 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 calculateExperiment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      calculateExperiment: (name: string, localStorageProp: string | boolean, variants: VariantData[], userEvents: UserEventHandler<UserEventsProps>) => {
        const localStorageKey = ExperimentsHelper.buildLocalStorageKey(localStorageProp)
        const totalWeight = ExperimentsHelper.calcTotalWeight(variants)
    
        ExperimentsHelper.loadOutcomes()
    Severity: Minor
    Found in packages/experiments/src/lib/ExperimentsHelper.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 View has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const View: React.FC = () => {
      const [storedBoolean, setStoredBoolean] = useLocalStorage<boolean>('test_boolean', false)
    
      const [defaultObject, setDefaultObject] = useLocalStorage<object | undefined>('test_object', { bar: true, foo: false })
    
    
    Severity: Minor
    Found in packages/shared/src/hooks/useLocalStorage.stories.tsx - About 1 hr to fix

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

        const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {
          if (busy) {
            // If it is busy, do not allow href clicks
            event.preventDefault()
          } else {
      Severity: Minor
      Found in packages/button/src/components/ButtonExBase.tsx - About 1 hr to fix

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

        export const useEthWallet = (connector: EthWalletConnectorBase): EthWallet => {
          const [currentAccount, additionalAccounts] = useCurrentAccount(connector)
        
          const chainId = useChainId(connector)
        
        
        Severity: Minor
        Found in packages/crypto/src/wallets/third-party/hooks/useEthWallet.tsx - About 1 hr to fix

          Function NumberStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          const NumberStatus: React.FC<NumberStatusProps> = ({
            error,
            format = '0[.]0a',
            color = 'primary',
            title,
          Severity: Minor
          Found in packages/number-status/src/NumberStatus.tsx - 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 Outer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const Outer: FC = () => {
            const [outerValue, setOuterValue] = useState<boolean>()
            return (
              <div style={{ border: 'solid 1px yellow' }}>
                <div>Outer</div>
          Severity: Minor
          Found in packages/hooks/src/useResetState.stories.tsx - About 1 hr to fix

            Function useRenderSpinCheck has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const useRenderSpinCheck = (bounce: RenderSpinCheckBounce, config?: RenderSpinCheckConfig) => {
              const startTime = useMemo(() => Date.now(), [])
              const [error, setError] = useState<Error>()
            
              useEffect(() => {
            Severity: Minor
            Found in packages/render-spin-check/src/hooks/useRenderSpinCheck.tsx - About 1 hr to fix

              Function useBusyTiming has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export const useBusyTiming = (busy?: boolean, busyMinimum = 0) => {
                const [internalBusy, setInternalBusy] = useState(false)
                const [busyStart, setBusyStart] = useState(0)
              
                const timer = useMemo(
              Severity: Minor
              Found in packages/flexbox/src/hooks/useBusyTiming.tsx - About 45 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 calcSpacing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export const calcSpacing = (theme: Theme, values: BoxProps['margin'][]) => {
                for (const value of values) {
                  if (value !== undefined) {
                    if (typeof value === 'string') {
                      return value
              Severity: Minor
              Found in packages/shared/src/calcSpacing.ts - 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

              Function getSelectedVariant has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                getSelectedVariant: (name: string) => {
                  const outcomes = ExperimentsHelper.loadOutcomes()
                  const experiment = ExperimentsHelper.getExperiment(name)
                  let total = 0
                  if (experiment && outcomes) {
              Severity: Minor
              Found in packages/experiments/src/lib/ExperimentsHelper.ts - 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 'xl'
              Severity: Major
              Found in packages/shared/src/hooks/useBreakpoint.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return defaultValue
                Severity: Major
                Found in packages/shared/src/hooks/useLocalStorage.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return <InfuraEthersLoader>{children}</InfuraEthersLoader>
                  Severity: Major
                  Found in packages/crypto/src/contexts/Ethers/Loader.tsx - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return <OperaEthersLoader>{children}</OperaEthersLoader>
                    Severity: Major
                    Found in packages/crypto/src/contexts/Ethers/Loader.tsx - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language