ant-design/ant-design

View on GitHub

Showing 3,485 of 3,485 total issues

Function TransferList has 272 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TransferList = <RecordType extends KeyWiseTransferItem>(
  props: TransferListProps<RecordType>,
) => {
  const {
    prefixCls,
Severity: Major
Found in components/transfer/list.tsx - About 1 day to fix

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

      it('deprecated dateFullCellRender and monthFullCellRender', () => {
        resetWarned();
    
        const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
        const { container } = render(
    Severity: Major
    Found in components/calendar/__tests__/index.test.tsx and 1 other location - About 1 day to fix
    components/calendar/__tests__/index.test.tsx on lines 500..522

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

    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('deprecated dateCellRender and monthCellRender', () => {
        resetWarned();
    
        const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
        const { container } = render(
    Severity: Major
    Found in components/calendar/__tests__/index.test.tsx and 1 other location - About 1 day to fix
    components/calendar/__tests__/index.test.tsx on lines 524..544

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

    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 useSelection has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
    Open

    const useSelection = <RecordType extends AnyObject = AnyObject>(
      config: UseSelectionConfig<RecordType>,
      rowSelection?: TableRowSelection<RecordType>,
    ): readonly [TransformColumns<RecordType>, Set<Key>] => {
      const {
    Severity: Minor
    Found in components/table/hooks/useSelection.tsx - About 1 day 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 useSelection.tsx has 606 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as React from 'react';
    import { useCallback, useMemo } from 'react';
    import DownOutlined from '@ant-design/icons/DownOutlined';
    import classNames from 'classnames';
    import { INTERNAL_COL_DEFINE } from 'rc-table';
    Severity: Major
    Found in components/table/hooks/useSelection.tsx - About 1 day to fix

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

      const generateData = (_level: number, _preKey?: React.Key, _tns?: TreeDataNode[]) => {
        const preKey = _preKey || '0';
        const tns = _tns || defaultData;
      
        const children: React.Key[] = [];
      Severity: Major
      Found in components/tree/demo/draggable.tsx and 1 other location - About 1 day to fix
      components/tree/demo/search.tsx on lines 12..32

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

      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 generateData = (_level: number, _preKey?: React.Key, _tns?: TreeDataNode[]) => {
        const preKey = _preKey || '0';
        const tns = _tns || defaultData;
      
        const children: React.Key[] = [];
      Severity: Major
      Found in components/tree/demo/search.tsx and 1 other location - About 1 day to fix
      components/tree/demo/draggable.tsx on lines 10..30

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

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

      const genInputNumberStyles: GenerateStyle<InputNumberToken> = (token: InputNumberToken) => {
        const {
          componentCls,
          lineWidth,
          lineType,
      Severity: Major
      Found in components/input-number/style/index.ts - About 1 day to fix

        Function InternalFormItem has 255 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.ReactElement {
          const {
            name,
            noStyle,
            className,
        Severity: Major
        Found in components/form/FormItem/index.tsx - About 1 day to fix

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

          const data: DataType[] = [
            {
              key: 1,
              name: 'John Brown sr.',
              age: 60,
          Severity: Major
          Found in components/table/demo/tree-data.tsx and 1 other location - About 1 day to fix
          components/table/demo/tree-table-ellipsis.tsx on lines 13..76

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

          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('Radio type should not be override', () => {
              const onChange = jest.fn();
              const { container } = render(
                <Radio.Group onChange={onChange}>
                  <Radio value={1} type="1">
          Severity: Major
          Found in components/radio/__tests__/group.test.tsx and 1 other location - About 1 day to fix
          components/radio/__tests__/radio-button.test.tsx on lines 188..210

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

          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 data: DataType[] = [
            {
              key: 1,
              name: 'John Brown sr. John Brown sr. John Brown sr. John Brown sr. John Brown sr. John Brown sr.',
              age: 60,
          Severity: Major
          Found in components/table/demo/tree-table-ellipsis.tsx and 1 other location - About 1 day to fix
          components/table/demo/tree-data.tsx on lines 35..98

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

          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('Radio type should not be override', () => {
              const onChange = jest.fn();
              const { container } = render(
                <Radio.Group onChange={onChange}>
                  <Radio value={1} type="1">
          Severity: Major
          Found in components/radio/__tests__/radio-button.test.tsx and 1 other location - About 1 day to fix
          components/radio/__tests__/group.test.tsx on lines 177..199

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

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

          export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject => {
            const { treeCls, treeNodeCls, treeNodePadding, titleHeight, nodeSelectedBg, nodeHoverBg } = token;
            const treeCheckBoxMarginHorizontal = token.paddingXS;
          
            return {
          Severity: Major
          Found in components/tree/style/index.ts - About 1 day to fix

            Function Theme has 248 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const Theme: React.FC = () => {
              const { styles } = useStyle();
              const [locale, lang] = useLocale(locales);
              const isZhCN = lang === 'cn';
              const { search } = useLocation();
            Severity: Major
            Found in .dumi/pages/index/components/Theme/index.tsx - About 1 day to fix

              File panel.ts has 579 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { unit } from '@ant-design/cssinjs';
              import type { CSSObject } from '@ant-design/cssinjs';
              import { TinyColor } from '@ctrl/tinycolor';
              
              import type { GenerateStyle } from '../../theme/internal';
              Severity: Major
              Found in components/date-picker/style/panel.ts - About 1 day to fix

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

                const GlobalHolderWrapper = React.forwardRef<GlobalHolderRef, {}>((_, ref) => {
                  const [messageConfig, setMessageConfig] = React.useState<ConfigOptions>(getGlobalContext);
                
                  const sync = () => {
                    setMessageConfig(getGlobalContext);
                Severity: Major
                Found in components/message/index.tsx and 1 other location - About 1 day to fix
                components/notification/index.tsx on lines 85..106

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

                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 GlobalHolderWrapper = React.forwardRef<GlobalHolderRef, {}>((_, ref) => {
                  const [notificationConfig, setNotificationConfig] =
                    React.useState<GlobalConfigProps>(getGlobalContext);
                
                  const sync = () => {
                Severity: Major
                Found in components/notification/index.tsx and 1 other location - About 1 day to fix
                components/message/index.tsx on lines 101..121

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

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

                const genBaseStyle: GenerateStyle<DropdownToken> = (token) => {
                  const {
                    componentCls,
                    menuCls,
                    zIndexPopup,
                Severity: Major
                Found in components/dropdown/style/index.ts - About 1 day to fix

                  File index.test.tsx has 567 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /* eslint-disable react/no-unstable-nested-components */
                  import React, { useEffect, useRef } from 'react';
                  
                  import Tour from '..';
                  import mountTest from '../../../tests/shared/mountTest';
                  Severity: Major
                  Found in components/tour/__tests__/index.test.tsx - About 1 day to fix
                    Severity
                    Category
                    Status
                    Source
                    Language