fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

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

function load(options: StoryshotsOptions) {
  global.STORYBOOK_ENV = 'web-components';

  const storybook = jest.requireActual('@storybook/web-components');

addons/storyshots/storyshots-core/src/frameworks/html/loader.ts on lines 10..25
addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts on lines 16..31
addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts on lines 11..26
addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts on lines 13..28
addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts on lines 11..26

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

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

function load(options: StoryshotsOptions) {
  global.STORYBOOK_ENV = 'html';

  const storybook = jest.requireActual('@storybook/html');

addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts on lines 16..31
addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts on lines 11..26
addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts on lines 13..28
addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts on lines 11..26
addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts on lines 10..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 111.

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 entries = async (_: any, options: any) => {
  let result: string[] = [];

  result = result.concat(await options.presets.apply('previewEntries', [], options));

Severity: Major
Found in lib/builder-webpack4/src/presets/preview-preset.ts and 1 other location - About 3 hrs to fix
lib/builder-webpack5/src/presets/preview-preset.ts on lines 5..21

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

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

  beforeEach(() => {
    buildStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
    cpSpawnMock.spawn.mockImplementation(() => ({
      stdout: { on: () => {} },
      stderr: { on: () => {} },
Severity: Major
Found in app/angular/src/builders/start-storybook/index.spec.ts and 1 other location - About 3 hrs to fix
app/angular/src/builders/build-storybook/index.spec.ts on lines 52..59

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

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('transformSource', () => {
      const transformSource = (src?: string) => (src ? `formatted: ${src}` : 'no src');
      const parameters = { ...baseContext.parameters, docs: { transformSource } };
      expect(enhanceSource({ ...baseContext, parameters }).docs.source).toEqual({
        code: 'formatted: Source',
Severity: Major
Found in addons/docs/src/blocks/enhanceSource.test.ts and 1 other location - About 3 hrs to fix
addons/docs/src/blocks/enhanceSource.test.ts on lines 37..43

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

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('transformSource', () => {
      const transformSource = (src?: string) => (src ? `formatted: ${src}` : 'no src');
      const parameters = { ...baseContext.parameters, docs: { transformSource } };
      expect(enhanceSource({ ...baseContext, parameters }).docs.source).toEqual({
        code: 'formatted: storySource.source',
Severity: Major
Found in addons/docs/src/blocks/enhanceSource.test.ts and 1 other location - About 3 hrs to fix
addons/docs/src/blocks/enhanceSource.test.ts on lines 67..73

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

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

import { createFlowPropDef } from './createPropDef';
import { DocgenInfo } from '../types';

const PROP_NAME = 'propName';

Severity: Minor
Found in addons/docs/src/lib/docgen/flow/createPropDef.test.ts - About 3 hrs to fix

    Function constructor has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor() {
        this.channel = addons.getChannel();
    
        // Restore state from the parent window in case the iframe was reloaded.
        this.state = global.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ || {};
    Severity: Minor
    Found in lib/instrumenter/src/instrumenter.ts - About 3 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

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

      it('filters exports using excludeStories array', () => {
        const { stories } = processCSFFile(
          {
            default: { title: 'Component', excludeStories: ['x', 'z'] },
            x: () => 0,
    Severity: Major
    Found in lib/store/src/csf/processCSFFile.test.ts and 1 other location - About 3 hrs to fix
    lib/store/src/csf/processCSFFile.test.ts on lines 73..87

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

    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('filters exports using includeStories array', () => {
        const { stories } = processCSFFile(
          {
            default: { title: 'Component', includeStories: ['x', 'z'] },
            x: () => 0,
    Severity: Major
    Found in lib/store/src/csf/processCSFFile.test.ts and 1 other location - About 3 hrs to fix
    lib/store/src/csf/processCSFFile.test.ts on lines 105..119

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

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

      renderNotCollapsed() {
        const { name, data, keyPath, deep, addFormVisible, nextDeep } = this.state;
        const {
          isCollapsed,
          handleRemove,
    Severity: Major
    Found in lib/components/src/controls/react-editable-json-tree/JsonNodes.tsx - About 3 hrs to fix

      Function renderNotCollapsed has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        renderNotCollapsed() {
          const { name, data, keyPath, deep, nextDeep, addFormVisible } = this.state;
          const {
            isCollapsed,
            handleRemove,
      Severity: Major
      Found in lib/components/src/controls/react-editable-json-tree/JsonNodes.tsx - About 3 hrs to fix

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

        export const NoTabs = () => (
          <Consumer>
            {({ api }: Combo) => {
              return (
                <Preview
        Severity: Major
        Found in lib/ui/src/components/preview/preview.stories.tsx and 1 other location - About 3 hrs to fix
        lib/ui/src/components/preview/preview.stories.tsx on lines 92..104

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

        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 getCurrentFrames(): Window[] {
            if (this.config.page === 'manager') {
              const list: HTMLIFrameElement[] = [
                ...document.querySelectorAll('[data-is-storybook="true"]'),
              ];
        Severity: Major
        Found in lib/channel-postmessage/src/index.ts and 1 other location - About 3 hrs to fix
        lib/channel-postmessage/src/index.ts on lines 183..193

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

        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 function generateArray({ inferredType, ast }: InspectionResult): PropDefaultValue {
          const { depth } = inferredType as InspectionArray;
        
          if (depth <= 2) {
            const compactArray = generateArrayCode(ast, true);
        addons/docs/src/frameworks/react/lib/defaultValues/generateObject.ts on lines 7..19

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

        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 getLocalFrame(): Window[] {
            if (this.config.page === 'manager') {
              const list: HTMLIFrameElement[] = [...document.querySelectorAll('#storybook-preview-iframe')];
              return list.map((e) => e.contentWindow);
            }
        Severity: Major
        Found in lib/channel-postmessage/src/index.ts and 1 other location - About 3 hrs to fix
        lib/channel-postmessage/src/index.ts on lines 169..181

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

        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 function generateObject({ inferredType, ast }: InspectionResult): PropDefaultValue {
          const { depth } = inferredType as InspectionArray;
        
          if (depth === 1) {
            const compactObject = generateObjectCode(ast, true);
        addons/docs/src/frameworks/react/lib/defaultValues/generateArray.ts on lines 7..19

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

        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 HideFullscreen = () => (
          <Consumer>
            {({ api }: Combo) => {
              return (
                <Preview
        Severity: Major
        Found in lib/ui/src/components/preview/preview.stories.tsx and 1 other location - About 3 hrs to fix
        lib/ui/src/components/preview/preview.stories.tsx on lines 78..90

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

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

        import React, {
          FC,
          useCallback,
          useEffect,
          useMemo,
        Severity: Minor
        Found in lib/components/src/controls/Color.tsx - About 3 hrs to fix

          PreviewWeb has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class PreviewWeb<TFramework extends AnyFramework> {
            channel: Channel;
          
            serverChannel?: Channel;
          
          
          Severity: Minor
          Found in lib/preview-web/src/PreviewWeb.tsx - About 3 hrs to fix
            Severity
            Category
            Status
            Source
            Language