ant-design/ant-design

View on GitHub

Showing 3,485 of 3,485 total issues

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

  it('Should ColorRgbInput work correct', () => {
    const handleAlphaChange = jest.fn();
    const { container } = render(<ColorRgbInput prefixCls="test" onChange={handleAlphaChange} />);
    expect(container.querySelector('.test-rgb-input')).toBeTruthy();
    const rgbInputEls = container.querySelectorAll('.test-rgb-input input');
Severity: Major
Found in components/color-picker/__tests__/components.test.tsx and 1 other location - About 1 day to fix
components/color-picker/__tests__/components.test.tsx on lines 54..74

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

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

import type { CSSProperties } from 'react';
import type { CSSObject } from '@ant-design/cssinjs';
import { unit } from '@ant-design/cssinjs';
import { TinyColor } from '@ctrl/tinycolor';
import type { CssUtil } from 'antd-style';
Severity: Major
Found in components/menu/style/index.ts - About 1 day to fix

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

    import React, { useEffect, useMemo, useState } from 'react';
    import { createEvent, fireEvent, render } from '@testing-library/react';
    import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
    
    import { resetWarned } from '../../_util/warning';
    Severity: Major
    Found in components/color-picker/__tests__/index.test.tsx - About 1 day to fix

      Function getColumns has 299 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const getColumns = React.useMemo<FooterColumn[]>(() => {
          const isZhCN = lang === 'cn';
      
          const col1 = {
            title: <FormattedMessage id="app.footer.resources" />,
      Severity: Major
      Found in .dumi/theme/slots/Footer/index.tsx - About 1 day to fix

        Function InternalTable has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
        Open

        const InternalTable = <RecordType extends AnyObject = AnyObject>(
          props: InternalTableProps<RecordType>,
          ref: React.MutableRefObject<HTMLDivElement>,
        ) => {
          const {
        Severity: Minor
        Found in components/table/InternalTable.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 index.test.tsx has 643 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from 'react';
        import type { SingleValueType } from 'rc-cascader/lib/Cascader';
        
        import type { DefaultOptionType } from '..';
        import Cascader from '..';
        Severity: Major
        Found in components/cascader/__tests__/index.test.tsx - About 1 day to fix

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

                  <Layout>
                    <Sider width={200} style={{ background: colorBgContainer }}>
                      <Menu
                        mode="inline"
                        defaultSelectedKeys={['1']}
          Severity: Major
          Found in components/layout/demo/component-token.tsx and 1 other location - About 1 day to fix
          components/layout/demo/top-side-2.tsx on lines 50..78

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

          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

                <Layout>
                  <Sider width={200} style={{ background: colorBgContainer }}>
                    <Menu
                      mode="inline"
                      defaultSelectedKeys={['1']}
          Severity: Major
          Found in components/layout/demo/top-side-2.tsx and 1 other location - About 1 day to fix
          components/layout/demo/component-token.tsx on lines 53..81

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

          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('should not show value attribute in input element after blur it', async () => {
              jest.useFakeTimers();
              const { container } = render(<Input.Password />);
              fireEvent.change(container.querySelector('input')!, { target: { value: 'value' } });
              await waitFakeTimer();
          Severity: Major
          Found in components/input/__tests__/Password.test.tsx and 1 other location - About 1 day to fix
          components/input/__tests__/Password.test.tsx on lines 119..133

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

          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('should not show value attribute in input element after toggle visibility', async () => {
              jest.useFakeTimers();
              const { container } = render(<Input.Password />);
              fireEvent.change(container.querySelector('input')!, { target: { value: 'value' } });
              await waitFakeTimer();
          Severity: Major
          Found in components/input/__tests__/Password.test.tsx and 1 other location - About 1 day to fix
          components/input/__tests__/Password.test.tsx on lines 84..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 259.

          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('should correctly when useState', () => {
              const App: React.FC = () => {
                const [query, setQuery] = useState('');
                return (
                  <TextArea
          Severity: Major
          Found in components/input/__tests__/textarea.test.tsx and 1 other location - About 1 day to fix
          components/input/__tests__/index.test.tsx on lines 398..422

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

          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('should correctly when useState', () => {
              const App: React.FC = () => {
                const [query, setQuery] = useState('');
                return (
                  <Input
          Severity: Major
          Found in components/input/__tests__/index.test.tsx and 1 other location - About 1 day to fix
          components/input/__tests__/textarea.test.tsx on lines 387..410

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

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

              (columns: ColumnsType<RecordType>): ColumnsType<RecordType> => {
                // >>>>>>>>>>> Skip if not exists `rowSelection`
                if (!rowSelection) {
                  warning(
                    !columns.includes(SELECTION_COLUMN),
          Severity: Major
          Found in components/table/hooks/useSelection.tsx - About 1 day to fix

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

            const items: MenuItem[] = [
              { key: '1', icon: <PieChartOutlined />, label: 'Option 1' },
              { key: '2', icon: <DesktopOutlined />, label: 'Option 2' },
              { key: '3', icon: <ContainerOutlined />, label: 'Option 3' },
              {
            Severity: Major
            Found in components/menu/demo/inline-collapsed.tsx and 1 other location - About 1 day to fix
            components/menu/demo/component-token.tsx on lines 60..104

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

            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 items2: MenuItem[] = [
              {
                key: '1',
                icon: <PieChartOutlined />,
                label: 'Option 1',
            Severity: Major
            Found in components/menu/demo/component-token.tsx and 1 other location - About 1 day to fix
            components/menu/demo/inline-collapsed.tsx on lines 16..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 257.

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

            function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
              const {
                tablePrefixCls,
                prefixCls,
                column,
            Severity: Minor
            Found in components/table/hooks/useFilter/FilterDropdown.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

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

              it('test submenu in mode inline', () => {
                const defaultTestProps: MenuProps = { mode: 'inline' };
                const Demo: React.FC<MenuProps> = (props) => (
                  <Menu {...defaultTestProps} {...props}>
                    <SubMenu key="1" title="submenu1">
            Severity: Major
            Found in components/menu/__tests__/index.test.tsx and 1 other location - About 1 day to fix
            components/menu/__tests__/index.test.tsx on lines 331..350

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

            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('test submenu in mode vertical', () => {
                const defaultTestProps: MenuProps = { mode: 'vertical' };
                const Demo: React.FC<MenuProps> = (props) => (
                  <Menu {...defaultTestProps} {...props}>
                    <SubMenu key="1" title="submenu1">
            Severity: Major
            Found in components/menu/__tests__/index.test.tsx and 1 other location - About 1 day to fix
            components/menu/__tests__/index.test.tsx on lines 311..329

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

            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

                      <div className={cardBody}>
                        <div className={left}>
                          <img src={ANTD_IMG_URL} alt="antd" />
                          <div>
                            <p className={title}>Ant Design</p>
            Severity: Major
            Found in .dumi/theme/slots/Content/ColumnCard.tsx and 1 other location - About 1 day to fix
            .dumi/theme/slots/Content/ColumnCard.tsx on lines 126..155

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

            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

                    <div className={cardBody}>
                      <div className={left}>
                        <img src={ANTD_IMG_URL} alt="antd" />
                        <div>
                          <p className={title}>Ant Design</p>
            Severity: Major
            Found in .dumi/theme/slots/Content/ColumnCard.tsx and 1 other location - About 1 day to fix
            .dumi/theme/slots/Content/ColumnCard.tsx on lines 160..189

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

            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