fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

Function withKeyboardCycle has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const withKeyboardCycle = (Component: React.ComponentType<ToolbarMenuProps>) => {
  const WithKeyboardCycle = (props: ToolbarMenuProps) => {
    const {
      id,
      toolbar: { items, shortcuts },
Severity: Minor
Found in addons/toolbars/src/hoc/withKeyboardCycle.tsx - About 1 hr to fix

    Function createArgTypes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const createArgTypes = (docgen: SvelteComponentDoc) => {
      const results: StrictArgTypes = {};
      docgen.data.forEach((item) => {
        results[item.name] = {
          control: parseTypeToControl(item.type),
    Severity: Minor
    Found in addons/docs/src/frameworks/svelte/extractArgTypes.ts - About 1 hr to fix

      Function checkRef has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          checkRef: async (ref) => {
            const { id, url, version, type } = ref;
            const isPublic = type === 'server-checked';
      
            // ref's type starts as either 'unknown' or 'server-checked'
      Severity: Minor
      Found in lib/api/src/modules/refs.ts - About 1 hr to fix

        Function transformer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function transformer(file, api) {
          const j = api.jscodeshift;
          const root = j(file.source);
        
          // FIXME: save out all the storyFn.story = { ... }
        Severity: Minor
        Found in lib/codemod/src/transforms/csf-to-mdx.js - About 1 hr 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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        function run() {
          const prompts = require('prompts');
          const program = require('commander');
          const chalk = require('chalk');
          const log = require('npmlog');
        Severity: Minor
        Found in scripts/bootstrap.js - About 1 hr 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 configure has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        function configure<TFramework extends AnyFramework>(
          options: {
            storybook: ClientApi<TFramework>;
          } & StoryshotsOptions
        ): void {
        Severity: Minor
        Found in addons/storyshots/storyshots-core/src/frameworks/configure.ts - About 1 hr 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 init has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        export const init: ModuleFn = ({ store, fullAPI }) => {
          const api: SubAPI = {
            getGlobals() {
              return store.getState().globals;
            },
        Severity: Minor
        Found in lib/api/src/modules/globals.ts - About 1 hr 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 eventToShortcut has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        export const eventToShortcut = (e: KeyboardEvent): KeyCollection | null => {
          // Meta key only doesn't map to a shortcut
          if (['Meta', 'Alt', 'Control', 'Shift'].includes(e.key)) {
            return null;
          }
        Severity: Minor
        Found in lib/api/src/lib/shortcut.ts - About 1 hr 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 map has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        const map = (arg: unknown, type: SBType): any => {
          if (arg === undefined || arg === null || !type) return arg;
          switch (type.name) {
            case 'string':
              return String(arg);
        Severity: Minor
        Found in lib/store/src/args.ts - About 1 hr 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

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

        LoggedIn.play = async ({ canvasElement }) => {
          const canvas = within(canvasElement);
          const loginButton = await canvas.getByRole('button', { name: /Log in/i });
          await userEvent.click(loginButton);
        };
        Severity: Major
        Found in lib/cli/src/frameworks/angular/Page.stories.ts and 1 other location - About 1 hr to fix
        lib/cli/src/frameworks/react/ts/Page.stories.tsx on lines 22..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 70.

        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

          return Object.entries(qs.parse(parts.join(';'), QS_OPTIONS)).reduce((acc, [key, value]) => {
            if (validateArgs(key, value)) return Object.assign(acc, { [key]: value });
            once.warn(dedent`
              Omitted potentially unsafe URL args.
        
        
        Severity: Major
        Found in lib/preview-web/src/parseArgsParam.ts and 1 other location - About 1 hr to fix
        lib/router/src/utils.ts on lines 118..126

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

        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

        LoggedIn.play = async ({ canvasElement }) => {
          const canvas = within(canvasElement);
          const loginButton = await canvas.getByRole('button', { name: /Log in/i });
          await userEvent.click(loginButton);
        };
        Severity: Major
        Found in lib/cli/src/frameworks/react/ts/Page.stories.tsx and 1 other location - About 1 hr to fix
        lib/cli/src/frameworks/angular/Page.stories.ts on lines 32..36

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

        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

        function parse(source) {
          try {
            return parseJs.parsers.babel.parse(source);
          } catch (error1) {
            try {
        lib/source-loader/src/abstract-syntax-tree/parsers/parser-ts.js on lines 3..13

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

        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

          const object = Object.entries(update).reduce((acc, [key, value]) => {
            if (validateArgs(key, value)) return Object.assign(acc, { [key]: value });
            once.warn(dedent`
              Omitted potentially unsafe URL args.
        
        
        Severity: Major
        Found in lib/router/src/utils.ts and 1 other location - About 1 hr to fix
        lib/preview-web/src/parseArgsParam.ts on lines 65..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 70.

        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

        function parse(source) {
          try {
            return parseTs.parsers.typescript.parse(source);
          } catch (error1) {
            try {
        lib/source-loader/src/abstract-syntax-tree/parsers/parser-js.js on lines 3..13

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

        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

            store.set({
              globals: {
                arg1: 'arg1',
                arg2: 2,
              },
        Severity: Major
        Found in lib/store/src/GlobalsStore.test.ts and 1 other location - About 1 hr to fix
        lib/store/src/GlobalsStore.test.ts on lines 100..109

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

        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(buildStandaloneMock).toHaveBeenCalledWith({
              angularBrowserTarget: 'angular-cli:build-2',
              angularBuilderContext: expect.any(Object),
              angularBuilderOptions: {},
              configDir: '.storybook',
        Severity: Major
        Found in app/angular/src/builders/build-storybook/index.spec.ts and 1 other location - About 1 hr to fix
        app/angular/src/builders/build-storybook/index.spec.ts on lines 77..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 70.

        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(buildStandaloneMock).toHaveBeenCalledWith({
              angularBrowserTarget: 'angular-cli:build-2',
              angularBuilderContext: expect.any(Object),
              angularBuilderOptions: {},
              configDir: '.storybook',
        Severity: Major
        Found in app/angular/src/builders/build-storybook/index.spec.ts and 1 other location - About 1 hr to fix
        app/angular/src/builders/build-storybook/index.spec.ts on lines 155..165

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

        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

              store.set({
                globals: {
                  arg1: 'arg1',
                  arg2: 2,
                },
        Severity: Major
        Found in lib/store/src/GlobalsStore.test.ts and 1 other location - About 1 hr to fix
        lib/store/src/GlobalsStore.test.ts on lines 24..33

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

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

        const buildTemplate = (
          selector: string,
          innerTemplate: string,
          inputs: string,
          outputs: string
          Severity
          Category
          Status
          Source
          Language