fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

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

    it('should only consider the last @returns tag when there is multiple', () => {
      const { extractedTags } = parseJsDoc('@returns {string}\n@returns {number}');

      expect(extractedTags.returns).not.toBeNull();
      expect(extractedTags.returns.type).not.toBeNull();
Severity: Major
Found in addons/docs/src/lib/jsdocParser.test.ts and 1 other location - About 3 hrs to fix
addons/docs/src/lib/jsdocParser.test.ts on lines 232..238

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

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 @returns with a type', () => {
      const { extractedTags } = parseJsDoc('@returns {string}');

      expect(extractedTags.returns).not.toBeNull();
      expect(extractedTags.returns.type).not.toBeNull();
Severity: Major
Found in addons/docs/src/lib/jsdocParser.test.ts and 1 other location - About 3 hrs to fix
addons/docs/src/lib/jsdocParser.test.ts on lines 260..266

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

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

import global from 'global';
import { PREVIEW_KEYDOWN } from '@storybook/core-events';

import { ModuleFn } from '../index';

Severity: Minor
Found in lib/api/src/modules/shortcuts.ts - About 3 hrs to fix

    Function convert has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const convert = (inherit: ThemeVars = themes[getPreferredColorScheme()]): Theme => {
      const {
        base,
        colorPrimary,
        colorSecondary,
    Severity: Major
    Found in lib/theming/src/convert.ts - About 3 hrs to fix

      Function renderStoryToElement has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        renderStoryToElement({
          story,
          renderContext: renderContextWithoutStoryContext,
          element: canvasElement,
          viewMode,
      Severity: Major
      Found in lib/preview-web/src/PreviewWeb.tsx - About 3 hrs to fix

        File icons.tsx has 311 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Icon paths
        export const icons = {
          mobile:
            'M648 64h-272c-66.274 0-120 53.726-120 120v656c0 66.274 53.726 120 120 120h272c66.274 0 120-53.726 120-120v-656c0-66.274-53.726-120-120-120zM376 144h272c22.056 0 40 17.944 40 40v495.968h-352v-495.968c0-22.056 17.946-40 40-40zM648 880h-272c-22.054 0-40-17.944-40-40v-80.032h352v80.032c0 22.056-17.944 40-40 40zM544.034 819.962c0 17.676-14.33 32.002-32.004 32.002-17.67 0-32-14.326-32-32.002 0-17.672 14.33-31.998 32-31.998 17.674-0 32.004 14.326 32.004 31.998z',
          watch:
        Severity: Minor
        Found in lib/components/src/icon/icons.tsx - About 3 hrs to fix

          Function invoke has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

            invoke(fn: Function, call: Call, options: Options) {
              // TODO this doesnt work because the abortSignal we have here is the newly created one
              // const { abortSignal } = global.window.__STORYBOOK_PREVIEW__ || {};
              // if (abortSignal && abortSignal.aborted) throw IGNORED_EXCEPTION;
          
          
          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

          Function transformStoriesRawToStoriesHash has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

          export const transformStoriesRawToStoriesHash = (
            input: StoriesRaw,
            { provider, prepared = true }: { provider: Provider; prepared?: Story['prepared'] }
          ): StoriesHash => {
            const values = Object.values(input).filter(Boolean);
          Severity: Minor
          Found in lib/api/src/lib/stories.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

          Function buildDevStandalone has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

          export async function buildDevStandalone(options: CLIOptions & LoadOptions & BuilderOptions) {
            const { packageJson, versionUpdates, releaseNotes } = options;
            const { version, name = '' } = packageJson;
          
            // updateInfo and releaseNotesData are cached, so this is typically pretty fast
          Severity: Minor
          Found in lib/core-server/src/build-dev.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

          File Object.tsx has 309 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import global from 'global';
          import cloneDeep from 'lodash/cloneDeep';
          import React, {
            ComponentProps,
            SyntheticEvent,
          Severity: Minor
          Found in lib/components/src/controls/Object.tsx - About 3 hrs to fix

            Function run has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function run() {
              const prompts = require('prompts');
              const program = require('commander');
              const chalk = require('chalk');
            
            
            Severity: Major
            Found in scripts/build-package.js - About 3 hrs to fix

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

              export const storyIndex: StoryIndex = {
                v: 3,
                stories: {
                  'component-one--a': {
                    id: 'component-one--a',
              Severity: Major
              Found in lib/preview-web/src/PreviewWeb.mockdata.ts and 1 other location - About 3 hrs to fix
              lib/store/src/StoryStore.test.ts on lines 47..69

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

              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

              const storyIndex: StoryIndex = {
                v: 3,
                stories: {
                  'component-one--a': {
                    id: 'component-one--a',
              Severity: Major
              Found in lib/store/src/StoryStore.test.ts and 1 other location - About 3 hrs to fix
              lib/preview-web/src/PreviewWeb.mockdata.ts on lines 37..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 103.

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

              const getDummyCompodocJson = () => {
                return {
                  miscellaneous: {
                    typealiases: [
                      {
              Severity: Major
              Found in addons/docs/src/frameworks/angular/compodoc.test.ts - About 3 hrs to fix

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

                  root
                    .find(j.VariableDeclarator)
                    .filter(
                      (expr) =>
                        expr.node.init.type === 'CallExpression' &&
                Severity: Major
                Found in lib/codemod/src/transforms/mdx-to-csf.js and 1 other location - About 3 hrs to fix
                lib/codemod/src/transforms/mdx-to-csf.js on lines 154..162

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

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

                    it('should support short object in enum summary', () => {
                      const component = createTestComponent({
                        type: {
                          name: 'enum',
                          value: [
                addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx on lines 362..382
                addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx on lines 442..462

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

                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

                  root
                    .find(j.AssignmentExpression)
                    .filter(
                      (expr) =>
                        expr.node.left.type === 'MemberExpression' &&
                Severity: Major
                Found in lib/codemod/src/transforms/mdx-to-csf.js and 1 other location - About 3 hrs to fix
                lib/codemod/src/transforms/mdx-to-csf.js on lines 143..151

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

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

                  const sidebarToggle = useMemo(
                    () => ({
                      id: 'S',
                      title: 'Show sidebar',
                      onClick: () => api.toggleNav(),
                Severity: Major
                Found in lib/ui/src/containers/menu.tsx and 2 other locations - About 3 hrs to fix
                lib/ui/src/containers/menu.tsx on lines 98..107
                lib/ui/src/containers/menu.tsx on lines 109..118

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

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

                export const bail: WebpackBuilder['bail'] = (e: Error) => {
                  if (reject) {
                    reject();
                  }
                  if (process) {
                Severity: Major
                Found in lib/manager-webpack4/src/index.ts and 3 other locations - About 3 hrs to fix
                lib/builder-webpack4/src/index.ts on lines 109..122
                lib/builder-webpack5/src/index.ts on lines 98..111
                lib/manager-webpack5/src/index.ts on lines 122..135

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

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

                export const bail: WebpackBuilder['bail'] = (e: Error) => {
                  if (reject) {
                    reject();
                  }
                  if (process) {
                Severity: Major
                Found in lib/manager-webpack5/src/index.ts and 3 other locations - About 3 hrs to fix
                lib/builder-webpack4/src/index.ts on lines 109..122
                lib/builder-webpack5/src/index.ts on lines 98..111
                lib/manager-webpack4/src/index.ts on lines 123..136

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

                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