fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

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

  onKeydown(event: KeyboardEvent) {
    if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || event.repeat) return;
    if (event.code === 'Enter' || event.key === 'Enter') {
      event.preventDefault();
      this.handleEdit();
lib/components/src/controls/react-editable-json-tree/JsonNodes.tsx on lines 548..558

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

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

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

export const babelLoader = () => {
  const { plugins, presets } = getStorybookBabelConfig();

  return {
    test: /\.(mjs|tsx?|jsx?)$/,
Severity: Major
Found in lib/manager-webpack5/src/presets/babel-loader-manager.ts and 1 other location - About 5 hrs to fix
lib/manager-webpack4/src/presets/babel-loader-manager.ts on lines 4..29

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

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

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

export const babelLoader = () => {
  const { plugins, presets } = getStorybookBabelConfig();

  return {
    test: /\.(mjs|tsx?|jsx?)$/,
Severity: Major
Found in lib/manager-webpack4/src/presets/babel-loader-manager.ts and 1 other location - About 5 hrs to fix
lib/manager-webpack5/src/presets/babel-loader-manager.ts on lines 4..29

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

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

export default function transformer(file, api) {
  const j = api.jscodeshift;
  const code = mdx.sync(file.source, {});
  const root = j(code);

Severity: Major
Found in lib/codemod/src/transforms/mdx-to-csf.js - About 5 hrs to fix

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

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 99..121
    app/angular/src/client/preview/decorateStory.test.ts on lines 165..187
    app/angular/src/client/preview/decorateStory.test.ts on lines 198..220

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

    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

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 99..121
    app/angular/src/client/preview/decorateStory.test.ts on lines 132..154
    app/angular/src/client/preview/decorateStory.test.ts on lines 198..220

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

    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

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 99..121
    app/angular/src/client/preview/decorateStory.test.ts on lines 132..154
    app/angular/src/client/preview/decorateStory.test.ts on lines 165..187

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

    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

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 132..154
    app/angular/src/client/preview/decorateStory.test.ts on lines 165..187
    app/angular/src/client/preview/decorateStory.test.ts on lines 198..220

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

    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('allows the snippet output to be modified by onBeforeRender', async () => {
        const storyFn = (args: any) => <div>args story</div>;
        const onBeforeRender = (dom: string) => `<p>${dom}</p>`;
        const jsx = { onBeforeRender };
        const context = makeContext('args', { __isArgsStory: true, jsx }, {});
    Severity: Major
    Found in addons/docs/src/frameworks/react/jsxDecorator.test.tsx and 1 other location - About 5 hrs to fix
    addons/docs/src/frameworks/react/jsxDecorator.test.tsx on lines 243..256

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

    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('allows the snippet output to be modified by transformSource', async () => {
        const storyFn = (args: any) => <div>args story</div>;
        const transformSource = (dom: string) => `<p>${dom}</p>`;
        const jsx = { transformSource };
        const context = makeContext('args', { __isArgsStory: true, jsx }, {});
    Severity: Major
    Found in addons/docs/src/frameworks/react/jsxDecorator.test.tsx and 1 other location - About 5 hrs to fix
    addons/docs/src/frameworks/react/jsxDecorator.test.tsx on lines 228..241

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

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

      const runGenerator: () => Promise<void> = () => {
        switch (projectType) {
          case ProjectType.ALREADY_HAS_STORYBOOK:
            logger.log();
            paddedLog('There seems to be a Storybook already available in this project.');
    Severity: Major
    Found in lib/cli/src/initiate.ts - About 5 hrs to fix

      Function init has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

      export const init: ModuleFn = ({ store, provider, singleStory }) => {
        const api = {
          toggleFullscreen(toggled?: boolean) {
            return store.setState(
              (state: State) => {
      Severity: Minor
      Found in lib/api/src/modules/layout.ts - About 5 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

      File Tree.tsx has 392 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import type { Group, Story, StoriesHash } from '@storybook/api';
      import { isRoot, isStory } from '@storybook/api';
      import { styled } from '@storybook/theming';
      import { Button, Icons } from '@storybook/components';
      import { transparentize } from 'polished';
      Severity: Minor
      Found in lib/ui/src/components/sidebar/Tree.tsx - About 5 hrs to fix

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

          it('shows the release notes after upgrading a major version', async () => {
            const version = '4.0.0';
            const set = jest.fn((...args: any[]) => Promise.resolve());
            const cache = { get: () => Promise.resolve(['3.0.0']), set };
        
        
        Severity: Major
        Found in lib/core-server/src/build-dev.test.ts and 1 other location - About 5 hrs to fix
        lib/core-server/src/build-dev.test.ts on lines 42..53

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

        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('support named function with arguments', () => {
              const result = parse('function concat(a, b) {}');
              const inferredType = result.inferredType as InspectionFunction;
        
              expect(inferredType.type).toBe(InspectionType.FUNCTION);
        addons/docs/src/frameworks/react/lib/inspection/acornParser.test.ts on lines 199..208

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

        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('support named function', () => {
              const result = parse('function concat() {}');
              const inferredType = result.inferredType as InspectionFunction;
        
              expect(inferredType.type).toBe(InspectionType.FUNCTION);
        addons/docs/src/frameworks/react/lib/inspection/acornParser.test.ts on lines 210..219

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

        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('shows the release notes after upgrading a minor version', async () => {
            const version = '4.1.0';
            const set = jest.fn((...args: any[]) => Promise.resolve());
            const cache = { get: () => Promise.resolve(['4.0.0']), set };
        
        
        Severity: Major
        Found in lib/core-server/src/build-dev.test.ts and 1 other location - About 5 hrs to fix
        lib/core-server/src/build-dev.test.ts on lines 29..40

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

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

          render() {
            const { children, bounds, options, theme, viewMode, docsOnly, panelCount } = this.props;
            const { isDragging, resizerNav, resizerPanel } = this.state;
        
            const margin = theme.layoutMargin;
        Severity: Major
        Found in lib/ui/src/components/layout/container.tsx - About 5 hrs to fix

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

            describe('when angular.json have empty projects entry', () => {
              beforeEach(() => {
                initMockWorkspace('empty-projects-entry');
              });
              it('should return webpack base config and display log error', async () => {
          Severity: Major
          Found in app/angular/src/server/framework-preset-angular-cli.test.ts and 3 other locations - About 5 hrs to fix
          app/angular/src/server/framework-preset-angular-cli.test.ts on lines 59..80
          app/angular/src/server/framework-preset-angular-cli.test.ts on lines 105..126
          app/angular/src/server/framework-preset-angular-cli.test.ts on lines 128..149

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

          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

            describe("when angular.json haven't projects entry", () => {
              beforeEach(() => {
                initMockWorkspace('without-projects-entry');
              });
              it('should return webpack base config and display log error', async () => {
          Severity: Major
          Found in app/angular/src/server/framework-preset-angular-cli.test.ts and 3 other locations - About 5 hrs to fix
          app/angular/src/server/framework-preset-angular-cli.test.ts on lines 82..103
          app/angular/src/server/framework-preset-angular-cli.test.ts on lines 105..126
          app/angular/src/server/framework-preset-angular-cli.test.ts on lines 128..149

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

          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