fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

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

      expect(projectAnnotations.renderToDOM).toHaveBeenCalledWith(
        expect.objectContaining({
          forceRemount: false,
          storyContext: expect.objectContaining({
            initialArgs: { foo: 'a' },
Severity: Major
Found in lib/preview-web/src/PreviewWeb.test.ts and 1 other location - About 2 hrs to fix
lib/preview-web/src/PreviewWeb.test.ts on lines 724..733

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

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

      it('should return "func" when the prop have a description without JSDoc tags', () => {
        const component = createTestComponent({
          type: {
            name: 'func',
          },
addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx on lines 523..534

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

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

    <IconButton
      key="zoomout"
      onClick={(e: MouseEvent<HTMLButtonElement>) => {
        e.preventDefault();
        zoom(1.25);
Severity: Major
Found in lib/components/src/blocks/Toolbar.tsx and 1 other location - About 2 hrs to fix
lib/components/src/blocks/Toolbar.tsx on lines 32..41

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

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

      it('should return a func signature when there is JSDoc tags.', () => {
        const component = createTestComponent({
          type: {
            name: 'func',
          },
addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx on lines 510..521

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

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

      expect(projectAnnotations.renderToDOM).toHaveBeenCalledWith(
        expect.objectContaining({
          forceRemount: false,
          storyContext: expect.objectContaining({
            initialArgs: { foo: 'a' },
Severity: Major
Found in lib/preview-web/src/PreviewWeb.test.ts and 1 other location - About 2 hrs to fix
lib/preview-web/src/PreviewWeb.test.ts on lines 1004..1013

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

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 jsxDecorator.test.tsx has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
import React from 'react';
import PropTypes from 'prop-types';
import { addons, StoryContext, useEffect } from '@storybook/addons';
import { renderJsx, jsxDecorator } from './jsxDecorator';
Severity: Minor
Found in addons/docs/src/frameworks/react/jsxDecorator.test.tsx - About 2 hrs to fix

    File jsdocParser.test.ts has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { parseJsDoc } from './jsdocParser';
    
    describe('parseJsDoc', () => {
      it('should set includesJsDoc to false when the value is null', () => {
        const { includesJsDoc, description, extractedTags } = parseJsDoc(null);
    Severity: Minor
    Found in addons/docs/src/lib/jsdocParser.test.ts - About 2 hrs to fix

      Function automigrate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export const automigrate = async ({ fixId, dryRun, yes }: FixOptions = {}) => {
        const packageManager = JsPackageManagerFactory.getPackageManager();
        const filtered = fixId ? fixes.filter((f) => f.id === fixId) : fixes;
      
        for (let i = 0; i < filtered.length; i += 1) {
      Severity: Minor
      Found in lib/cli/src/automigrate/index.ts - About 2 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

      Function repro has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export const repro = async ({
        outputDirectory,
        list,
        template,
        framework,
      Severity: Minor
      Found in lib/cli/src/repro.ts - About 2 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

      Function parseValue has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const parseValue = (value: string): ParsedColor | undefined => {
        if (!value) return undefined;
        let valid = true;
      
        if (RGB_REGEXP.test(value)) {
      Severity: Major
      Found in lib/components/src/controls/Color.tsx - About 2 hrs to fix

        Function useSharedState has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function useSharedState<S>(stateId: string, defaultState?: S) {
          const api = useStorybookApi();
          const existingState = api.getAddonState<S>(stateId);
          const state = orDefault<S>(
            existingState,
        Severity: Major
        Found in lib/api/src/index.tsx - About 2 hrs to fix

          File StoryStore.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import memoize from 'memoizerific';
          import {
            Parameters,
            StoryId,
            StoryContextForLoaders,
          Severity: Minor
          Found in lib/store/src/StoryStore.ts - About 2 hrs to fix

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

            export const Story1 = () => (
              <Vertical>
                <pre>START, when switching stories, you should be able to read this at the top of the page</pre>
                <pre style={{ height: '100vh' }}>middle</pre>
                <pre>
            Severity: Major
            Found in examples/official-storybook/stories/core/scroll.stories.js and 1 other location - About 2 hrs to fix
            examples/official-storybook/stories/core/scroll.stories.js on lines 28..37

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

            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

            export const Story2 = () => (
              <Vertical>
                <pre>START, when switching stories, you should be able to read this at the top of the page</pre>
                <pre style={{ height: '100vh' }}>middle</pre>
                <pre>
            Severity: Major
            Found in examples/official-storybook/stories/core/scroll.stories.js and 1 other location - About 2 hrs to fix
            examples/official-storybook/stories/core/scroll.stories.js on lines 16..25

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

            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

            program
              .command('repro [outputDirectory]')
              .description('Create a reproduction from a set of possible templates')
              .option('-f --framework <framework>', 'Filter on given framework')
              .option('-t --template <template>', 'Use the given template')
            Severity: Major
            Found in lib/cli/src/generate.ts and 1 other location - About 2 hrs to fix
            lib/cli/src/generate.ts on lines 21..30

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

            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

            program
              .command('init')
              .description('Initialize Storybook into your project.')
              .option('-f --force', 'Force add Storybook')
              .option('-s --skip-install', 'Skip installing deps')
            Severity: Major
            Found in lib/cli/src/generate.ts and 1 other location - About 2 hrs to fix
            lib/cli/src/generate.ts on lines 103..117

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

            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 visualizer.ts has 252 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* eslint-disable operator-assignment */
            /**
             * Based on https://gist.github.com/awestbro/e668c12662ad354f02a413205b65fce7
             */
            import global from 'global';
            Severity: Minor
            Found in addons/measure/src/box-model/visualizer.ts - About 2 hrs to fix

              Function webpackFinal has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function webpackFinal(baseConfig: webpack.Configuration, options: PresetOptions) {
                if (!moduleIsAvailable('@angular-devkit/build-angular')) {
                  logger.info('=> Using base config because "@angular-devkit/build-angular" is not installed');
                  return baseConfig;
                }
              Severity: Major
              Found in app/angular/src/server/framework-preset-angular-cli.ts - About 2 hrs to fix

                Function withGrid has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const withGrid = (
                  StoryFn: StoryFunction<AnyFramework>,
                  context: StoryContext<AnyFramework>
                ) => {
                  const { globals, parameters } = context;
                Severity: Major
                Found in addons/backgrounds/src/decorators/withGrid.ts - About 2 hrs to fix

                  Function loadPreset has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function loadPreset(
                    input: PresetConfig,
                    level: number,
                    storybookOptions: InterPresetOptions
                  ): LoadedPreset[] {
                  Severity: Major
                  Found in lib/core-common/src/presets.ts - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language