ant-design/ant-design

View on GitHub
components/color-picker/__tests__/index.test.tsx

Summary

Maintainability
F
4 days
Test Coverage

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

        const Demo = () => {
          const [disabled, setDisabled] = useState(false);
          return (
            <div className="App">
              <ColorPicker disabled={disabled} />
    Severity: Minor
    Found in components/color-picker/__tests__/index.test.tsx - About 1 hr to fix

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

        it('Should rgb input work', async () => {
          const { container } = render(<ColorPicker open format="rgb" />);
          const rgbInputEls = container.querySelectorAll('.ant-color-picker-rgb-input input');
          fireEvent.change(rgbInputEls[0], {
            target: { value: 99 },
      Severity: Major
      Found in components/color-picker/__tests__/index.test.tsx and 1 other location - About 6 hrs to fix
      components/color-picker/__tests__/index.test.tsx on lines 313..328

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

      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 hsb input work', async () => {
          const { container } = render(<ColorPicker open format="hsb" />);
          const hsbInputEls = container.querySelectorAll('.ant-color-picker-hsb-input input');
          fireEvent.change(hsbInputEls[0], {
            target: { value: 0 },
      Severity: Major
      Found in components/color-picker/__tests__/index.test.tsx and 1 other location - About 6 hrs to fix
      components/color-picker/__tests__/index.test.tsx on lines 296..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 174.

      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 defaultFormat work', () => {
          const { container } = render(<ColorPicker open defaultFormat="hsb" />);
          expect(container.querySelector('.ant-color-picker-hsb-input')).toBeTruthy();
        });
      Severity: Major
      Found in components/color-picker/__tests__/index.test.tsx and 1 other location - About 1 hr to fix
      components/typography/__tests__/ellipsis.test.tsx on lines 304..307

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

      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

          it('default undefined, normal', () => {
            const { container } = render(<Demo />);
      
            expect(container.querySelector('.ant-color-picker-clear')).toBeFalsy();
          });
      Severity: Major
      Found in components/color-picker/__tests__/index.test.tsx and 2 other locations - About 1 hr to fix
      components/color-picker/__tests__/index.test.tsx on lines 54..57
      components/color-picker/__tests__/index.test.tsx on lines 607..610

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

      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

        it('Should clear show when value not set', () => {
          const { container } = render(<ColorPicker />);
          expect(container.querySelector('.ant-color-picker-clear')).toBeTruthy();
        });
      Severity: Major
      Found in components/color-picker/__tests__/index.test.tsx and 2 other locations - About 1 hr to fix
      components/color-picker/__tests__/index.test.tsx on lines 54..57
      components/color-picker/__tests__/index.test.tsx on lines 727..731

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

      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

        it('Should component render correct', () => {
          const { container } = render(<ColorPicker />);
          expect(container.querySelector('.ant-color-picker-trigger')).toBeTruthy();
        });
      Severity: Major
      Found in components/color-picker/__tests__/index.test.tsx and 2 other locations - About 1 hr to fix
      components/color-picker/__tests__/index.test.tsx on lines 607..610
      components/color-picker/__tests__/index.test.tsx on lines 727..731

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

      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

            useEffect(() => {
              if (typeof props.value !== 'undefined') {
                setColor(props.value);
              }
            }, [props.value]);
      Severity: Minor
      Found in components/color-picker/__tests__/index.test.tsx and 1 other location - About 35 mins to fix
      components/color-picker/__tests__/index.test.tsx on lines 679..683

      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

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

            useEffect(() => {
              if (typeof props.value !== 'undefined') {
                setColor(props.value);
              }
            }, [props.value]);
      Severity: Minor
      Found in components/color-picker/__tests__/index.test.tsx and 1 other location - About 35 mins to fix
      components/color-picker/__tests__/index.test.tsx on lines 650..654

      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

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

          const { container } = render(
            <ColorPicker defaultValue="#1677ff" showText={(color) => color.toHexString()} />,
          );
      Severity: Minor
      Found in components/color-picker/__tests__/index.test.tsx and 1 other location - About 35 mins to fix
      components/input/__tests__/otp.test.tsx on lines 131..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 46.

      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