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 override pre-existing args, if undefined', () => {
      const args = inferActionsFromArgTypesRegex({
        initialArgs: {},
        argTypes,
        parameters,
Severity: Major
Found in addons/actions/src/preset/addArgsHelpers.test.ts and 1 other location - About 2 hrs to fix
addons/actions/src/preset/addArgsHelpers.test.ts on lines 9..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 93.

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 writeStats = async (directory: string, name: string, stats: Stats) => {
  const filePath = path.join(directory, `${name}-stats.json`);
  await fs.outputFile(filePath, JSON.stringify(stats.toJson(), null, 2), 'utf8');
  return filePath;
};
Severity: Major
Found in lib/manager-webpack5/src/utils/output-stats.ts and 1 other location - About 2 hrs to fix
lib/manager-webpack4/src/utils/output-stats.ts on lines 19..23

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

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 writeStats = async (directory: string, name: string, stats: Stats) => {
  const filePath = path.join(directory, `${name}-stats.json`);
  await fs.outputFile(filePath, JSON.stringify(stats.toJson(), null, 2), 'utf8');
  return filePath;
};
Severity: Major
Found in lib/manager-webpack4/src/utils/output-stats.ts and 1 other location - About 2 hrs to fix
lib/manager-webpack5/src/utils/output-stats.ts on lines 19..23

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

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

import { styled } from '@storybook/theming';

export const DocumentWrapper = styled.div<{}>(({ theme }) => ({
  fontSize: `${theme.typography.size.s2}px`,
  lineHeight: '1.6',
Severity: Minor
Found in lib/components/src/typography/DocumentWrapper.tsx - About 2 hrs to fix

    Function Ref has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const Ref: FunctionComponent<RefType & RefProps> = React.memo((props) => {
      const api = useStorybookApi();
      const {
        stories,
        id: refId,
    Severity: Major
    Found in lib/ui/src/components/sidebar/Refs.tsx - About 2 hrs to fix

      Function convertToStories has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function convertToStories(path) {
          const base = j(path);
      
          const meta = {};
          const includeStories = [];
      Severity: Major
      Found in lib/codemod/src/transforms/mdx-to-csf.js - About 2 hrs to fix

        Function puppeteerTest has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const puppeteerTest = (customConfig: Partial<PuppeteerTestConfig> = {}) => {
          const {
            storybookUrl,
            chromeExecutablePath,
            getGotoOptions,
        Severity: Major
        Found in addons/storyshots/storyshots-puppeteer/src/puppeteerTest.ts - About 2 hrs to fix

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

                    children: [
                      {
                        pathSegment: 'webpack',
                        title: 'Webpack',
                        type: 'link',
          Severity: Major
          Found in docs/toc.js and 1 other location - About 2 hrs to fix
          examples/web-components-kitchen-sink/.storybook/preview.js on lines 31..37

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 91.

          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

                  {
                    pathSegment: '',
                    title: 'User interface',
                    type: 'menu',
                    children: [
          Severity: Major
          Found in docs/toc.js and 1 other location - About 2 hrs to fix
          docs/toc.js on lines 209..235

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

          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

                items: [
                  { value: 'en', right: '🇺🇸', title: 'English' },
                  { value: 'es', right: '🇪🇸', title: 'Español' },
                  { value: 'fr', right: '🇫🇷', title: 'Français' },
                  { value: 'zh', right: '🇨🇳', title: '中文' },
          Severity: Major
          Found in examples/web-components-kitchen-sink/.storybook/preview.js and 1 other location - About 2 hrs to fix
          docs/toc.js on lines 354..380

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

          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

              {
                title: '🔖 Sharing',
                pathSegment: 'sharing',
                type: 'menu',
                children: [
          Severity: Major
          Found in docs/toc.js and 1 other location - About 2 hrs to fix
          docs/toc.js on lines 392..418

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

          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 FindBy: CSF2Story = (args) => {
            const [isLoading, setIsLoading] = React.useState(true);
            React.useEffect(() => {
              setTimeout(() => setIsLoading(false), 500);
            }, []);
          addons/interactions/src/components/AccountForm/addon-interactions.stories.tsx on lines 66..72

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

          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 WaitForElementToBeRemoved: CSF2Story = () => {
            const [isLoading, setIsLoading] = React.useState(true);
            React.useEffect(() => {
              setTimeout(() => setIsLoading(false), 1500);
            }, []);
          addons/interactions/src/components/AccountForm/addon-interactions.stories.tsx on lines 40..46

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

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

          import global from 'global';
          import React, { FunctionComponent, useMemo, ComponentProps, useCallback, forwardRef } from 'react';
          
          import { Icons, WithTooltip, Spaced, TooltipLinkList } from '@storybook/components';
          import { styled } from '@storybook/theming';
          Severity: Minor
          Found in lib/ui/src/components/sidebar/RefIndicator.tsx - About 2 hrs to fix

            File initiate.ts has 282 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { UpdateNotifier, Package } from 'update-notifier';
            import chalk from 'chalk';
            import prompts from 'prompts';
            import { detect, isStorybookInstalled, detectLanguage } from './detect';
            import { installableProjectTypes, ProjectType, Builder, CoreBuilder } from './project_types';
            Severity: Minor
            Found in lib/cli/src/initiate.ts - About 2 hrs to fix

              Function Panel has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const Panel: React.FC<AddonPanelProps> = (props) => {
                const [storyId, setStoryId] = React.useState<StoryId>();
                const [controlStates, setControlStates] = React.useState<ControlStates>(INITIAL_CONTROL_STATES);
                const [isPlaying, setPlaying] = React.useState(false);
                const [scrollTarget, setScrollTarget] = React.useState<HTMLElement>();
              Severity: Major
              Found in addons/interactions/src/Panel.tsx - About 2 hrs to fix

                Function render has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    const { name, value, editEnabled, keyPath, deep } = this.state;
                    const {
                      handleRemove,
                      originalValue,
                Severity: Major
                Found in lib/components/src/controls/react-editable-json-tree/JsonNodes.tsx - About 2 hrs to fix

                  Function extractJsDocTags has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function extractJsDocTags(ast: doctrine.Annotation): ExtractedJsDoc {
                    const extractedTags: ExtractedJsDoc = {
                      params: null,
                      returns: null,
                      ignore: false,
                  Severity: Minor
                  Found in addons/docs/src/lib/jsdocParser.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 getDerivedStateFromProps has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                    static getDerivedStateFromProps(props: LayoutProps, state: LayoutState) {
                      const { bounds, options } = props;
                      const { resizerPanel, resizerNav } = state;
                  
                      const isNavHidden = options.isFullscreen || !options.showNav;
                  Severity: Minor
                  Found in lib/ui/src/components/layout/container.tsx - 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 buildStaticStandalone has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export async function buildStaticStandalone(options: CLIOptions & LoadOptions & BuilderOptions) {
                    /* eslint-disable no-param-reassign */
                    options.configType = 'PRODUCTION';
                  
                    if (options.outputDir === '') {
                  Severity: Minor
                  Found in lib/core-server/src/build-static.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

                  Severity
                  Category
                  Status
                  Source
                  Language