xylabs/sdk-react

View on GitHub

Showing 148 of 148 total issues

Function Experiments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const Experiments: React.FC<ExperimentsProps> = (props) => {
  const { name, children, localStorageProp = true } = props
  const userEvents = useUserEvents()
  const localStorageKey = buildLocalStorageKey(localStorageProp)
  const childList = makeChildrenArray(children)
Severity: Minor
Found in packages/experiments/src/components/Experiments.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

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

const StorybookEntry = {
  args: {
    open: true,
  },
  component: WalletDiscoveryPaper,
packages/crypto/src/wallets/components/Discovery/MenuItems.stories.tsx on lines 5..17

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

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

const StorybookEntry = {
  args: {
    open: true,
  },
  component: WalletsDiscoveredMenuItems,
packages/crypto/src/wallets/components/Discovery/Paper.stories.tsx on lines 12..24

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

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 updateCanvas has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const updateCanvas = (canvas: React.RefObject<HTMLCanvasElement>, props: IdenticonProps) => {
  const { value = '', size = 400, bg = 'transparent', count = 5, palette, iconPadding = 0 } = props
  let { fg } = props
  const hash = md5(value)
  const block = Math.floor(size / count)
Severity: Minor
Found in packages/identicon/src/components/Identicon.tsx - About 1 hr to fix

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

    const FlexCol = forwardRef<unknown, FlexBoxProps>((props, ref) => {
      return <BusyBox alignItems="center" display="flex" flexDirection="column" justifyContent="center" ref={ref} {...props} />
    })
    Severity: Major
    Found in packages/flexbox/src/components/FlexCol.tsx and 1 other location - About 1 hr to fix
    packages/flexbox/src/components/FlexRow.tsx on lines 6..8

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

    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

    const FlexRow = forwardRef<unknown, FlexBoxProps>((props, ref) => {
      return <BusyBox alignItems="center" display="flex" flexDirection="row" justifyContent="center" ref={ref} {...props} />
    })
    Severity: Major
    Found in packages/flexbox/src/components/FlexRow.tsx and 1 other location - About 1 hr to fix
    packages/flexbox/src/components/FlexCol.tsx on lines 6..8

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

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

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

      private getDcs() {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        const global = window as any
        if (!global._dcs) {
          throw new Error('DCS not found')
    Severity: Major
    Found in packages/pixel/src/lib/Tracking/Drip/BaseEvent.ts and 1 other location - About 1 hr to fix
    packages/pixel/src/lib/Tracking/Drip/BaseEvent.ts on lines 29..36

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

    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

      private getDcq() {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        const global = window as any
        if (!global._dcq) {
          throw new Error('DCQ not found')
    Severity: Major
    Found in packages/pixel/src/lib/Tracking/Drip/BaseEvent.ts and 1 other location - About 1 hr to fix
    packages/pixel/src/lib/Tracking/Drip/BaseEvent.ts on lines 38..45

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

    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 ThemeEnabledComponent has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const ThemeEnabledComponent = () => {
      const theme = useTheme()
      const { darkMode, lightMode, mode, setMode } = useColorSchemeEx()
    
      return (

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

          light: {
            palette: {
              background: {
                default: '#fff',
                paper: '#fff',
      packages/invertible-theme/src/CssVarsProvider/InvertibleCssVarsProvider.stories.tsx on lines 60..76

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

      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

          dark: {
            palette: {
              background: {
                default: '#303030',
                paper: '#424242',
      packages/invertible-theme/src/CssVarsProvider/InvertibleCssVarsProvider.stories.tsx on lines 77..93

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

      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 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 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 } = useCookieConsent()
      
        const onScroll = () => {
          //hide it one the user has scrolled at least one page
      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 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 Experiments has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

          async testStarted(data: T | TestStartedFields) {
            await Promise.allSettled(this.handlers.map((handler) => handler.testStarted(data)))
          }
        Severity: Major
        Found in packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts and 3 other locations - About 1 hr to fix
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 21..23
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 29..31
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 33..35

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

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

          async userClick(data: T | UserClickFields) {
            await Promise.allSettled(this.handlers.map((handler) => handler.userClick(data)))
          }
        Severity: Major
        Found in packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts and 3 other locations - About 1 hr to fix
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 21..23
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 25..27
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 33..35

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

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

          async funnelStarted(data: T | FunnelStartedFields) {
            await Promise.allSettled(this.handlers.map((handler) => handler.funnelStarted(data)))
          }
        Severity: Major
        Found in packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts and 3 other locations - About 1 hr to fix
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 25..27
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 29..31
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 33..35

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

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

          async viewContent(data: T | ViewContentFields) {
            await Promise.allSettled(this.handlers.map((handler) => handler.viewContent(data)))
          }
        Severity: Major
        Found in packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts and 3 other locations - About 1 hr to fix
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 21..23
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 25..27
        packages/pixel/src/lib/Tracking/XyoUserEventHandler.ts on lines 29..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 57.

        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