fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

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

  test('retrieve non-existent returns undefined', () => {
    const value = {};
    const inputs = ['NONEXISTENT', { testkey: value, x: 'incorrect' }];
    const output = utils.get(inputs[0], inputs[1]);

Severity: Major
Found in lib/ui/src/components/sidebar/utils.test.js and 1 other location - About 2 hrs to fix
lib/ui/src/components/sidebar/utils.test.js on lines 29..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 81.

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

  test('retrieved by key', () => {
    const value = {};
    const inputs = ['testkey', { testkey: value, x: 'incorrect' }];
    const output = utils.get(inputs[0], inputs[1]);

Severity: Major
Found in lib/ui/src/components/sidebar/utils.test.js and 1 other location - About 2 hrs to fix
lib/ui/src/components/sidebar/utils.test.js on lines 36..42

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

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('will pull args from context', () => {
      run(
        () => {},
        [
          (storyFn) => {
Severity: Major
Found in lib/store/src/hooks.test.js and 1 other location - About 2 hrs to fix
lib/store/src/hooks.test.js on lines 555..566

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

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(argTypes).toEqual({
        a: { name: 'a-story', type: booleanType },
        b: { name: 'b-component', type: stringType },
        c: { name: 'c-global', type: numberType },
        nested: { name: 'nested', type: booleanType, a: 'story', b: 'component', c: 'global' },
Severity: Major
Found in lib/store/src/csf/prepareStory.test.ts and 1 other location - About 2 hrs to fix
lib/store/src/csf/prepareStory.test.ts on lines 278..283

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

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

          argTypes: {
            a: { name: 'a-global', type: numberType },
            b: { name: 'b-global', type: numberType },
            c: { name: 'c-global', type: numberType },
            nested: { name: 'nested', type: booleanType, a: 'global', b: 'global', c: 'global' },
Severity: Major
Found in lib/store/src/csf/prepareStory.test.ts and 1 other location - About 2 hrs to fix
lib/store/src/csf/prepareStory.test.ts on lines 287..292

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

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

/* eslint-disable no-underscore-dangle */
/* global window */

import { ArgType, ArgTypes } from '@storybook/api';
import { logger } from '@storybook/client-logger';
Severity: Minor
Found in addons/docs/src/frameworks/angular/compodoc.ts - About 2 hrs to fix

    File shortcuts.tsx has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { Component } from 'react';
    import { styled, keyframes } from '@storybook/theming';
    
    import {
      eventToShortcut,
    Severity: Minor
    Found in lib/ui/src/settings/shortcuts.tsx - About 2 hrs to fix

      Function transformer has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function transformer(file, api) {
        const j = api.jscodeshift;
        const root = j(file.source);
      
        /**
      Severity: Major
      Found in lib/codemod/src/transforms/update-addon-info.js - About 2 hrs to fix

        Function measureElement has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function measureElement(element: HTMLElement): ElementMeasurements {
          const style = global.getComputedStyle(element);
          // eslint-disable-next-line prefer-const
          let { top, left, right, bottom, width, height } = element.getBoundingClientRect();
        
        
        Severity: Major
        Found in addons/measure/src/box-model/visualizer.ts - About 2 hrs to fix

          Function StoryTable has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          > = (props) => {
            const context = useContext(DocsContext);
            const { id: currentId, componentStories } = context;
            const {
              story: storyName,
          Severity: Major
          Found in addons/docs/src/blocks/ArgsTable.tsx - About 2 hrs to fix

            Function Preview has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const Preview = React.memo<PreviewProps>((props) => {
              const {
                api,
                id: previewId,
                options,
            Severity: Major
            Found in lib/ui/src/components/preview/preview.tsx - About 2 hrs to fix

              File project_types.ts has 261 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { validRange, minVersion } from '@storybook/semver';
              
              function ltMajor(versionRange: string, major: number) {
                // Uses validRange to avoid a throw from minVersion if an invalid range gets passed
                return validRange(versionRange) && minVersion(versionRange).major < major;
              Severity: Minor
              Found in lib/cli/src/project_types.ts - About 2 hrs to fix

                Function puppeteerTest has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                export const puppeteerTest = (customConfig: Partial<PuppeteerTestConfig> = {}) => {
                  const {
                    storybookUrl,
                    chromeExecutablePath,
                    getGotoOptions,
                Severity: Minor
                Found in addons/storyshots/storyshots-puppeteer/src/puppeteerTest.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 useProgressReporting has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                export const useProgressReporting = async (
                  router: Router,
                  startTime: [number, number],
                  options: any
                ): Promise<{ handler: any; modulesCount: number }> => {
                Severity: Minor
                Found in lib/core-common/src/utils/progress-reporting.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

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

                export const createBabelLoader = (options: any, framework: string) => ({
                  test: useBaseTsSupport(framework) ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
                  use: [
                    {
                      loader: require.resolve('babel-loader'),
                Severity: Major
                Found in lib/builder-webpack4/src/preview/babel-loader-preview.ts and 1 other location - About 2 hrs to fix
                lib/builder-webpack5/src/preview/babel-loader-preview.ts on lines 12..22

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

                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 createBabelLoader = (options: any, framework: string) => ({
                  test: useBaseTsSupport(framework) ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
                  use: [
                    {
                      loader: require.resolve('babel-loader'),
                Severity: Major
                Found in lib/builder-webpack5/src/preview/babel-loader-preview.ts and 1 other location - About 2 hrs to fix
                lib/builder-webpack4/src/preview/babel-loader-preview.ts on lines 4..14

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

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

                export const getStorySortParameter = (previewCode: string) => {
                  let storySort: t.Expression;
                  const ast = babelParse(previewCode);
                  traverse(ast, {
                    ExportNamedDeclaration: {
                Severity: Major
                Found in lib/csf-tools/src/getStorySortParameter.ts - About 2 hrs to fix

                  Function parse has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    parse() {
                      // eslint-disable-next-line @typescript-eslint/no-this-alias
                      const self = this;
                      traverse(this._ast, {
                        ExportNamedDeclaration: {
                  Severity: Major
                  Found in lib/csf-tools/src/ConfigFile.ts - About 2 hrs to fix

                    File iframe-webpack.config.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import path from 'path';
                    import {
                      Configuration,
                      DefinePlugin,
                      HotModuleReplacementPlugin,
                    Severity: Minor
                    Found in lib/builder-webpack5/src/preview/iframe-webpack.config.ts - About 2 hrs to fix

                      Function renderSelection has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async renderSelection({ persistedArgs }: { persistedArgs?: Args } = {}) {
                          const { selection } = this.urlStore;
                          if (!selection) {
                            throw new Error('Cannot render story as no selection was made');
                          }
                      Severity: Major
                      Found in lib/preview-web/src/PreviewWeb.tsx - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language