nexxtway/react-rainbow

View on GitHub
src/components/Lookup/__test__/lookup.spec.js

Summary

Maintainability
D
2 days
Test Coverage

File lookup.spec.js has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import { mount } from 'enzyme';
import ButtonIcon from '../../ButtonIcon';
import Lookup from '..';
import StyledTextError from '../../Input/styled/errorText';
Severity: Minor
Found in src/components/Lookup/__test__/lookup.spec.js - About 5 hrs to fix

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

        it('should pass the right props to the Label component', () => {
            const component = mount(<Lookup label="custom label" required />);
            expect(component.find('Label').props()).toEqual({
                label: 'custom label',
                required: true,
    Severity: Major
    Found in src/components/Lookup/__test__/lookup.spec.js and 3 other locations - About 4 hrs to fix
    src/components/Input/inputBase/__test__/input.spec.js on lines 75..87
    src/components/Select/__test__/select.spec.js on lines 32..44
    src/components/Textarea/__test__/textarea.spec.js on lines 49..61

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

    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 set the onClearValue prop in SelectedValue component when pass readOnly', () => {
            const value = { label: 'New York', description: 'awesome city' };
            const component = mount(<Lookup label="custom label" value={value} readOnly />);
            expect(component.find('SelectedValue').prop('onClearValue')).toBeUndefined();
        });
    Severity: Major
    Found in src/components/Lookup/__test__/lookup.spec.js and 1 other location - About 2 hrs to fix
    src/components/Lookup/__test__/lookup.spec.js on lines 238..242

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

    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 set the onClearValue prop in SelectedValue component when pass disabled', () => {
            const value = { label: 'New York', description: 'awesome city' };
            const component = mount(<Lookup label="custom label" value={value} disabled />);
            expect(component.find('SelectedValue').prop('onClearValue')).toBeUndefined();
        });
    Severity: Major
    Found in src/components/Lookup/__test__/lookup.spec.js and 1 other location - About 2 hrs to fix
    src/components/Lookup/__test__/lookup.spec.js on lines 243..247

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

    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 options = [
                {
                    type: 'section',
                    label: 'European Cities',
                    options: [{ label: 'Paris', description: 'An awesome city' }, { label: 'Madrid' }],
    Severity: Major
    Found in src/components/Lookup/__test__/lookup.spec.js and 1 other location - About 2 hrs to fix
    src/components/Lookup/helpers/__test__/getNormalizedOptions.spec.js on lines 15..26

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

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

        it('should set type "search" in the input element', () => {
            const component = mount(<Lookup />);
            expect(component.find('input').prop('type')).toBe('search');
        });
    Severity: Major
    Found in src/components/Lookup/__test__/lookup.spec.js and 7 other locations - About 1 hr to fix
    src/components/CheckboxToggle/__test__/checkboxToggle.spec.js on lines 6..9
    src/components/MenuDivider/__test__/menuDivider.spec.js on lines 6..9
    src/components/RadioButtonGroup/__test__/radioButton.spec.js on lines 6..9
    src/components/Rating/__test__/star.spec.js on lines 6..9
    src/components/Table/body/__test__/selectableCell.spec.js on lines 16..19
    src/components/Table/head/__test__/selectableHeader.spec.js on lines 11..14
    src/components/Table/head/__test__/selectableHeader.spec.js on lines 19..22

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

    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