ant-design/ant-design

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

Summary

Maintainability
F
4 days
Test Coverage

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

import React from 'react';
import { CheckOutlined, HighlightOutlined, LikeOutlined, SmileOutlined } from '@ant-design/icons';
import copy from 'copy-to-clipboard';
import KeyCode from 'rc-util/lib/KeyCode';
import { resetWarned } from 'rc-util/lib/warning';
Severity: Minor
Found in components/typography/__tests__/index.test.tsx - About 5 hrs to fix

    Function copyTest has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          function copyTest(
            name: string,
            text?: string,
            target?: string,
            icon?: React.ReactNode,
    Severity: Major
    Found in components/typography/__tests__/index.test.tsx - About 2 hrs to fix

      Function copyTest has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              name: string,
              text?: string,
              target?: string,
              icon?: React.ReactNode,
              tooltips?: boolean | string[],
      Severity: Minor
      Found in components/typography/__tests__/index.test.tsx - About 45 mins to fix

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

              it('should trigger onStart when type Start', () => {
                const onStart = jest.fn();
                const { container: wrapper } = render(<Paragraph editable={{ onStart }}>Bamboo</Paragraph>);
                fireEvent.click(wrapper.querySelectorAll('.ant-typography-edit')[0]);
                fireEvent.keyDown(wrapper.querySelector('textarea')!, { keyCode: KeyCode.A });
        Severity: Major
        Found in components/typography/__tests__/index.test.tsx and 2 other locations - About 6 hrs to fix
        components/typography/__tests__/index.test.tsx on lines 393..400
        components/typography/__tests__/index.test.tsx on lines 411..420

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

        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 trigger onEnd when type Enter', () => {
                const onEnd = jest.fn();
                const { container: wrapper } = render(<Paragraph editable={{ onEnd }}>Bamboo</Paragraph>);
                fireEvent.click(wrapper.querySelectorAll('.ant-typography-edit')[0]);
                fireEvent.keyDown(wrapper.querySelector('textarea')!, { keyCode: KeyCode.ENTER });
        Severity: Major
        Found in components/typography/__tests__/index.test.tsx and 2 other locations - About 6 hrs to fix
        components/typography/__tests__/index.test.tsx on lines 402..409
        components/typography/__tests__/index.test.tsx on lines 411..420

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

        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 trigger onCancel when type ESC', () => {
                const onCancel = jest.fn();
                const { container: wrapper } = render(
                  <Paragraph editable={{ onCancel }}>Bamboo</Paragraph>,
                );
        Severity: Major
        Found in components/typography/__tests__/index.test.tsx and 2 other locations - About 6 hrs to fix
        components/typography/__tests__/index.test.tsx on lines 393..400
        components/typography/__tests__/index.test.tsx on lines 402..409

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

        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 get HTMLDivElement ref from Paragraph', () => {
            const ref = React.createRef<HTMLDivElement>();
            render(<Paragraph ref={ref} />);
            expect(ref.current instanceof HTMLDivElement).toBe(true);
          });
        Severity: Major
        Found in components/typography/__tests__/index.test.tsx and 1 other location - About 2 hrs to fix
        components/typography/__tests__/index.test.tsx on lines 478..482

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

        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 get HTMLSpanElement ref from Text', () => {
            const ref = React.createRef<HTMLSpanElement>();
            render(<Text ref={ref} />);
            expect(ref.current instanceof HTMLSpanElement).toBe(true);
          });
        Severity: Major
        Found in components/typography/__tests__/index.test.tsx and 1 other location - About 2 hrs to fix
        components/typography/__tests__/index.test.tsx on lines 472..476

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

        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