ant-design/ant-design

View on GitHub
components/transfer/__tests__/index.test.tsx

Summary

Maintainability
F
3 days
Test Coverage

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

import React, { useCallback, useEffect, useState } from 'react';
import { fireEvent, render, waitFor } from '@testing-library/react';
import type { DefaultRecordType } from 'rc-table/lib/interface';

import type { SelectAllLabel, TransferProps } from '..';
Severity: Major
Found in components/transfer/__tests__/index.test.tsx - About 1 day to fix

    Function App has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const App: React.FC = () => {
          const [mockData, setMockData] = useState<DefaultRecordType[]>([]);
          const [targetKeys, setTargetKeys] = useState<TransferProps['targetKeys']>([]);
    
          const getMock = () => {
    Severity: Minor
    Found in components/transfer/__tests__/index.test.tsx - About 1 hr to fix

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

            const getMock = () => {
              const tempTargetKeys = [];
              const tempMockData = [];
              for (let i = 0; i < 2; i++) {
                const data = {
      Severity: Major
      Found in components/transfer/__tests__/index.test.tsx and 3 other locations - About 6 hrs to fix
      components/transfer/demo/advanced.tsx on lines 16..33
      components/transfer/demo/custom-item.tsx on lines 16..33
      components/transfer/demo/search.tsx on lines 16..33

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 171.

      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 { container } = render(
            <Transfer
              {...listCommonProps}
              showSearch
              filterOption={filterOption}
      Severity: Minor
      Found in components/transfer/__tests__/index.test.tsx and 1 other location - About 50 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 243..250

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

      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 { getByText } = render(
            <Transfer
              {...listCommonProps}
              disabled
              onSelectChange={handleSelectChange}
      Severity: Minor
      Found in components/transfer/__tests__/index.test.tsx and 1 other location - About 50 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 304..311

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

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

          fireEvent.change(
            container
              ?.querySelectorAll('.ant-transfer-list')
              ?.item(0)
              ?.querySelector('input[type="text"]')!,
      Severity: Major
      Found in components/transfer/__tests__/index.test.tsx and 5 other locations - About 45 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 313..319
      components/transfer/__tests__/index.test.tsx on lines 341..347
      components/transfer/__tests__/index.test.tsx on lines 423..429
      components/transfer/__tests__/search.test.tsx on lines 90..96
      components/transfer/__tests__/search.test.tsx on lines 109..115

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

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

          fireEvent.change(
            container
              ?.querySelectorAll('.ant-transfer-list')
              ?.item(0)
              ?.querySelector('input[type="text"]')!,
      Severity: Major
      Found in components/transfer/__tests__/index.test.tsx and 5 other locations - About 45 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 341..347
      components/transfer/__tests__/index.test.tsx on lines 423..429
      components/transfer/__tests__/index.test.tsx on lines 493..499
      components/transfer/__tests__/search.test.tsx on lines 90..96
      components/transfer/__tests__/search.test.tsx on lines 109..115

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

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

          fireEvent.change(
            container
              ?.querySelectorAll('.ant-transfer-list')
              ?.item(0)
              ?.querySelector('input[type="text"]')!,
      Severity: Major
      Found in components/transfer/__tests__/index.test.tsx and 5 other locations - About 45 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 313..319
      components/transfer/__tests__/index.test.tsx on lines 423..429
      components/transfer/__tests__/index.test.tsx on lines 493..499
      components/transfer/__tests__/search.test.tsx on lines 90..96
      components/transfer/__tests__/search.test.tsx on lines 109..115

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

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

          fireEvent.change(
            container
              ?.querySelectorAll('.ant-transfer-list')
              ?.item(0)
              ?.querySelector('input[type="text"]')!,
      Severity: Major
      Found in components/transfer/__tests__/index.test.tsx and 5 other locations - About 45 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 313..319
      components/transfer/__tests__/index.test.tsx on lines 341..347
      components/transfer/__tests__/index.test.tsx on lines 493..499
      components/transfer/__tests__/search.test.tsx on lines 90..96
      components/transfer/__tests__/search.test.tsx on lines 109..115

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

      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

          const { getByText } = render(
            <Transfer
              {...listCommonProps}
              onSelectChange={handleSelectChange}
              render={(item) => item.title}
      Severity: Minor
      Found in components/transfer/__tests__/index.test.tsx and 2 other locations - About 40 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 131..137
      components/transfer/__tests__/index.test.tsx on lines 257..263

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

      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

          const { getByText } = render(
            <Transfer
              {...listCommonProps}
              onSelectChange={handleSelectChange}
              render={(item) => item.title}
      Severity: Minor
      Found in components/transfer/__tests__/index.test.tsx and 2 other locations - About 40 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 131..137
      components/transfer/__tests__/index.test.tsx on lines 144..150

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

      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

          const { getByTitle } = render(
            <Transfer
              {...listCommonProps}
              onSelectChange={handleSelectChange}
              render={(item) => item.title}
      Severity: Minor
      Found in components/transfer/__tests__/index.test.tsx and 2 other locations - About 40 mins to fix
      components/transfer/__tests__/index.test.tsx on lines 144..150
      components/transfer/__tests__/index.test.tsx on lines 257..263

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

      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

        dataSource: [
          { key: 'a', title: 'a' },
          { key: 'b', title: 'b' },
          { key: 'c', title: 'c', disabled: true },
        ],
      Severity: Minor
      Found in components/transfer/__tests__/index.test.tsx and 1 other location - About 35 mins to fix
      components/transfer/__tests__/list.test.tsx on lines 10..14

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

      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