ant-design/ant-design

View on GitHub
.dumi/theme/builtins/Previewer/CodePreviewer.tsx

Summary

Maintainability
F
5 days
Test Coverage

Function CodePreviewer has 452 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {
  const {
    asset,
    expand,
    iframe,
Severity: Major
Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx - About 2 days to fix

    File CodePreviewer.tsx has 534 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useContext, useEffect, useRef, useState } from 'react';
    import { LinkOutlined, ThunderboltOutlined, UpOutlined } from '@ant-design/icons';
    import type { Project } from '@stackblitz/sdk';
    import stackblitzSdk from '@stackblitz/sdk';
    import { Alert, Badge, Flex, Tooltip } from 'antd';
    Severity: Major
    Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx - About 1 day to fix

      Function CodePreviewer has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

      const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {
        const {
          asset,
          expand,
          iframe,
      Severity: Minor
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx - About 5 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

        const {
          asset,
          expand,
          iframe,
          demoUrl,
      Severity: Major
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx and 1 other location - About 2 hrs to fix
      components/select/style/token.ts on lines 129..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 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

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

                  <form
                    className="code-box-code-action"
                    action="https://codepen.io/pen/define"
                    method="POST"
                    target="_blank"
      Severity: Major
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx and 2 other locations - About 2 hrs to fix
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 421..436
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 473..492

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                    <form
                      className="code-box-code-action"
                      action="https://codesandbox.io/api/v1/sandboxes/define"
                      method="POST"
                      target="_blank"
      Severity: Major
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx and 2 other locations - About 2 hrs to fix
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 421..436
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 454..471

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                    <form
                      className="code-box-code-action"
                      action="//riddle.alibaba-inc.com/riddles/define"
                      method="POST"
                      target="_blank"
      Severity: Major
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx and 2 other locations - About 2 hrs to fix
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 454..471
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 473..492

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                      <img
                        alt="expand code"
                        src={
                          theme?.includes('dark')
                            ? 'https://gw.alipayobjects.com/zos/antfincdn/CjZPwcKUG3/OpROPHYqWmrMDBFMZtKF.svg'
      Severity: Major
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx and 1 other location - About 1 hr to fix
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 509..518

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

      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

                      <img
                        alt="expand code"
                        src={
                          theme?.includes('dark')
                            ? 'https://gw.alipayobjects.com/zos/antfincdn/btT3qDZn1U/wSAkBuJFbdxsosKKpqyq.svg'
      Severity: Major
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx and 1 other location - About 1 hr to fix
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx on lines 519..528

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

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

                <CodePreview
                  sourceCode={entryCode}
                  jsxCode={jsx}
                  styleCode={style}
                  error={liveDemoError}
      Severity: Major
      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx and 3 other locations - About 40 mins to fix
      components/avatar/avatar.tsx on lines 187..194
      components/notification/PurePanel.tsx on lines 115..122
      components/statistic/Statistic.tsx on lines 63..70

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

      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

      There are no issues that match your filters.

      Category
      Status