xylabs/sdk-react

View on GitHub
packages/shared/src/hooks/useLocalStorage.stories.tsx

Summary

Maintainability
A
2 hrs
Test Coverage

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

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

    const StorybookEntry = {
      argTypes: {},
      component: View,
      parameters: { docs: { page: null } },
      title: 'Hooks/useLocalStorage',
    Severity: Major
    Found in packages/shared/src/hooks/useLocalStorage.stories.tsx and 35 other locations - About 55 mins to fix
    packages/appbar/src/AppBar/Application.stories.tsx on lines 10..15
    packages/appbar/src/AppBarEx.stories.tsx on lines 9..14
    packages/appbar/src/SiteMenu/MenuListItem/MenuListItemContainer.stories.tsx on lines 10..15
    packages/appbar/src/Toolbar/Context/ContextToolbar.stories.tsx on lines 7..12
    packages/base-page/src/components/BasePage/BasePage.stories.tsx on lines 7..12
    packages/button/src/components/ButtonEx.stories.tsx on lines 8..13
    packages/common/src/components/Breadcrumbs/BreadcrumbsEx.stories.tsx on lines 7..12
    packages/cookie-consent/src/components/CookieConsent.stories.tsx on lines 49..54
    packages/crypto/src/components/EthAccount/EthAccountBox.stories.tsx on lines 10..15
    packages/crypto/src/components/EthAccount/EthAccountButton.stories.tsx on lines 8..13
    packages/crypto/src/components/TokenAmount/TokenAmount.stories.tsx on lines 19..24
    packages/crypto/src/wallets/third-party/Coinbase/Coinbase.stories.tsx on lines 12..17
    packages/crypto/src/wallets/third-party/MetaMask/MetaMask.stories.tsx on lines 12..17
    packages/crypto/src/wallets/third-party/Phantom/Phantom.stories.tsx on lines 12..17
    packages/crypto/src/wallets/third-party/Trust/Trust.stories.tsx on lines 12..17
    packages/dialogs/src/ErrorDialog.stories.tsx on lines 7..12
    packages/dialogs/src/MessageDialog.stories.tsx on lines 6..11
    packages/error/src/components/Errors/ErrorViewer.stories.tsx on lines 6..11
    packages/error/src/components/Errors/ErrorsViewer.stories.tsx on lines 7..12
    packages/error/src/contexts/ErrorReporter/Provider.stories.tsx on lines 9..14
    packages/experiments/src/components/Experiments.stories.tsx on lines 7..12
    packages/experiments/src/components/ExperimentsDebugger.stories.tsx on lines 6..11
    packages/experiments/src/hooks/useExperiments.stories.tsx on lines 42..47
    packages/flexbox/src/components/BusyBox/BusyBox.stories.tsx on lines 7..12
    packages/flexbox/src/components/FlexCol.stories.tsx on lines 7..12
    packages/flexbox/src/components/FlexRow.stories.tsx on lines 7..12
    packages/hooks/src/useResetState.stories.tsx on lines 66..71
    packages/invertible-theme/src/InvertibleMuiThemeProvider/InvertibleMuiThemeProvider.stories.tsx on lines 12..17
    packages/invertible-theme/src/InvertibleThemeProvider.stories.tsx on lines 9..14
    packages/link/src/LinkEx.stories.tsx on lines 8..13
    packages/number-status/src/NumberStatus.stories.tsx on lines 7..12
    packages/pixel-debugger/src/components/PixelDebugger.stories.tsx on lines 10..15
    packages/quick-tip-button/src/QuickTipButton.stories.tsx on lines 9..14
    packages/webapp/src/components/Chrome.stories.tsx on lines 13..18
    packages/webapp/src/components/NotFoundPage/Page.stories.tsx on lines 5..10

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

    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

    There are no issues that match your filters.

    Category
    Status