fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

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

function rules(
  { rules: defaultRules = [] }: Configuration['module'],
  { rules: customRules = [] }: Configuration['module']
): Configuration['module']['rules'] {
  return [...defaultRules, ...customRules];
Severity: Major
Found in lib/core-common/src/utils/merge-webpack-config.ts and 1 other location - About 2 hrs to fix
lib/core-common/src/utils/merge-webpack-config.ts on lines 17..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 84.

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 addonsOrientationToggle = useMemo(
    () => ({
      id: 'D',
      title: 'Change addons orientation',
      onClick: () => api.togglePanelPosition(),
Severity: Major
Found in lib/ui/src/containers/menu.tsx and 1 other location - About 2 hrs to fix
lib/ui/src/containers/menu.tsx on lines 197..206

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

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 collapse = useMemo(
    () => ({
      id: 'collapse',
      title: 'Collapse all',
      onClick: () => api.collapseAll(),
Severity: Major
Found in lib/ui/src/containers/menu.tsx and 1 other location - About 2 hrs to fix
lib/ui/src/containers/menu.tsx on lines 120..129

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

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

  useEffect(() => {
    Object.entries(eventMap).forEach(([type, listener]) => api.on(type, listener));
    return () => {
      Object.entries(eventMap).forEach(([type, listener]) => api.off(type, listener));
    };
Severity: Major
Found in lib/api/src/index.tsx and 1 other location - About 2 hrs to fix
lib/addons/src/hooks.ts on lines 395..402

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

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 Button: React.FC<ButtonProps> = ({
  primary = false,
  size = 'medium',
  backgroundColor,
  label,
Severity: Major
Found in examples/cra-ts-essentials/src/stories/Button.tsx and 1 other location - About 2 hrs to fix
lib/cli/src/frameworks/react/ts/Button.tsx on lines 30..48

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

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 Button = ({
  primary = false,
  size = 'medium',
  backgroundColor,
  label,
Severity: Major
Found in lib/cli/src/frameworks/react/ts/Button.tsx and 1 other location - About 2 hrs to fix
examples/cra-ts-essentials/src/stories/Button.tsx on lines 30..48

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

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

  useEffect(() => {
    Object.entries(eventMap).forEach(([type, listener]) => channel.on(type, listener));
    return () => {
      Object.entries(eventMap).forEach(([type, listener]) =>
        channel.removeListener(type, listener)
Severity: Major
Found in lib/addons/src/hooks.ts and 1 other location - About 2 hrs to fix
lib/api/src/index.tsx on lines 347..352

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

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 extensions(
  { extensions: defaultExtensions = [] }: Configuration['resolve'],
  { extensions: customExtensions = [] }: Configuration['resolve']
): Configuration['resolve']['extensions'] {
  return [...defaultExtensions, ...customExtensions];
Severity: Major
Found in lib/core-common/src/utils/merge-webpack-config.ts and 1 other location - About 2 hrs to fix
lib/core-common/src/utils/merge-webpack-config.ts on lines 10..15

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

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

export async function getWebpackConfig(baseConfig: webpack.Configuration, options: PresetOptions) {
  const dirToSearch = process.cwd();

  // Read angular workspace
  let workspaceConfig;
Severity: Major
Found in app/angular/src/server/angular-cli-webpack-older.ts - About 2 hrs to fix

    Function renderJsx has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const renderJsx = (code: React.ReactElement, options: JSXOptions) => {
      if (typeof code === 'undefined') {
        logger.warn('Too many skip or undefined component');
        return null;
      }
    Severity: Major
    Found in addons/docs/src/frameworks/react/jsxDecorator.tsx - About 2 hrs to fix

      Function parse has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        parse() {
          // eslint-disable-next-line @typescript-eslint/no-this-alias
          const self = this;
          traverse(this._ast, {
            ExportNamedDeclaration: {
      Severity: Minor
      Found in lib/csf-tools/src/ConfigFile.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 init has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      export const init: ModuleFn = ({ store, navigate, state, provider, fullAPI, ...rest }) => {
        const navigateTo = (path: string, queryParams: Record<string, string> = {}, options = {}) => {
          const params = Object.entries(queryParams)
            .filter(([, v]) => v)
            .sort(([a], [b]) => (a < b ? -1 : 1))
      Severity: Minor
      Found in lib/api/src/modules/url.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 validateOptions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      export const validateOptions = (args: Args, argTypes: ArgTypes): Args => {
        return Object.entries(argTypes).reduce((acc, [key, { options }]) => {
          if (!options) {
            if (key in args) {
              acc[key] = args[key];
      Severity: Minor
      Found in lib/store/src/args.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 Page has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const Page = () => {
        const [user, setUser] = React.useState();
      
        return (
          <article>
      Severity: Major
      Found in lib/cli/src/frameworks/react/js/Page.jsx - About 2 hrs to fix

        Function AllTypes has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const AllTypes = () => {
          function A() {}
          function B() {}
        
          const bound = B.bind({});
        Severity: Major
        Found in examples/official-storybook/stories/addon-actions.stories.js - About 2 hrs to fix

          Function BackgroundSelector has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const BackgroundSelector: FunctionComponent = memo(() => {
            const backgroundsConfig = useParameter<BackgroundsParameter>(
              BACKGROUNDS_PARAM_KEY,
              DEFAULT_BACKGROUNDS_CONFIG
            );
          Severity: Major
          Found in addons/backgrounds/src/containers/BackgroundSelector.tsx - About 2 hrs to fix

            Function Page has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const Page: React.VFC = () => {
              const [user, setUser] = React.useState<User>();
            
              return (
                <article>
            Severity: Major
            Found in lib/cli/src/frameworks/react/ts/Page.tsx - About 2 hrs to fix

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

                if (shortcuts && shortcuts.previous) {
                  await api.setAddonShortcut(ADDON_ID, {
                    label: shortcuts.previous.label,
                    defaultShortcut: shortcuts.previous.keys,
                    actionName: `${id}:previous`,
              Severity: Major
              Found in addons/toolbars/src/utils/register-shortcuts.ts and 2 other locations - About 2 hrs to fix
              addons/toolbars/src/utils/register-shortcuts.ts on lines 12..19
              addons/toolbars/src/utils/register-shortcuts.ts on lines 30..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 83.

              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

                if (shortcuts && shortcuts.next) {
                  await api.setAddonShortcut(ADDON_ID, {
                    label: shortcuts.next.label,
                    defaultShortcut: shortcuts.next.keys,
                    actionName: `${id}:next`,
              Severity: Major
              Found in addons/toolbars/src/utils/register-shortcuts.ts and 2 other locations - About 2 hrs to fix
              addons/toolbars/src/utils/register-shortcuts.ts on lines 21..28
              addons/toolbars/src/utils/register-shortcuts.ts on lines 30..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 83.

              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

                if (shortcuts && shortcuts.reset) {
                  await api.setAddonShortcut(ADDON_ID, {
                    label: shortcuts.reset.label,
                    defaultShortcut: shortcuts.reset.keys,
                    actionName: `${id}:reset`,
              Severity: Major
              Found in addons/toolbars/src/utils/register-shortcuts.ts and 2 other locations - About 2 hrs to fix
              addons/toolbars/src/utils/register-shortcuts.ts on lines 12..19
              addons/toolbars/src/utils/register-shortcuts.ts on lines 21..28

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

              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