nexxtway/react-rainbow

View on GitHub
src/components/Lookup/index.js

Summary

Maintainability
F
4 days
Test Coverage

File index.js has 601 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable react/sort-comp */
/* eslint-disable react/no-did-update-set-state, react/no-did-mount-set-state */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import RenderIf from '../RenderIf';
Severity: Major
Found in src/components/Lookup/index.js - About 1 day to fix

    Function render has 153 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        render() {
            const {
                style,
                className,
                label,
    Severity: Major
    Found in src/components/Lookup/index.js - About 6 hrs to fix

      Lookup has 36 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Lookup extends Component {
          constructor(props) {
              super(props);
              const normalizedOptions = getNormalizedOptions(props.options || []);
              this.state = {
      Severity: Minor
      Found in src/components/Lookup/index.js - About 4 hrs to fix

        Function constructor has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor(props) {
                super(props);
                const normalizedOptions = getNormalizedOptions(props.options || []);
                this.state = {
                    searchValue: '',
        Severity: Minor
        Found in src/components/Lookup/index.js - About 1 hr to fix

          Function componentDidUpdate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              componentDidUpdate(prevProps, prevState) {
                  const {
                      options: prevOptions,
                      preferredSelectedOption: prevPreferredSelectedOption,
                  } = prevProps;
          Severity: Minor
          Found in src/components/Lookup/index.js - About 1 hr to fix

            Function handleKeyDown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                handleKeyDown(event) {
                    const { searchValue } = this.state;
                    const { keyCode } = event;
            
                    if (keyCode === ESCAPE_KEY) {
            Severity: Minor
            Found in src/components/Lookup/index.js - About 45 mins 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

                options: PropTypes.arrayOf(
                    PropTypes.shape({
                        label: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
                        description: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
                        icon: PropTypes.node,
            Severity: Major
            Found in src/components/Lookup/index.js and 1 other location - About 2 hrs to fix
            src/components/Select/index.js on lines 142..148

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

            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

                value: PropTypes.oneOfType([
                    PropTypes.shape({
                        label: PropTypes.string,
                        description: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
                        icon: PropTypes.node,
            Severity: Major
            Found in src/components/Lookup/index.js and 1 other location - About 1 hr to fix
            src/components/Lookup/selectedValue.js on lines 145..152

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

            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

                handleFocus() {
                    const { onFocus, value } = this.props;
                    this.openMenu();
                    const eventValue = value || null;
                    onFocus(eventValue);
            Severity: Major
            Found in src/components/Lookup/index.js and 1 other location - About 1 hr to fix
            src/components/Lookup/index.js on lines 177..182

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

                handleBlur() {
                    const { onBlur, value } = this.props;
                    this.closeMenu();
                    const eventValue = value || null;
                    onBlur(eventValue);
            Severity: Major
            Found in src/components/Lookup/index.js and 1 other location - About 1 hr to fix
            src/components/Lookup/index.js on lines 170..175

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

                                            <RenderIf isTrue={showScrollDownArrow}>
                                                <MenuArrowButton
                                                    arrow="down"
                                                    onMouseEnter={this.handleScrollDownArrowHover}
                                                    onMouseLeave={this.stopArrowScoll}
            Severity: Minor
            Found in src/components/Lookup/index.js and 1 other location - About 55 mins to fix
            src/components/Lookup/index.js on lines 560..566

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

            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

                                            <RenderIf isTrue={showScrollUpArrow}>
                                                <MenuArrowButton
                                                    arrow="up"
                                                    onMouseEnter={this.handleScrollUpArrowHover}
                                                    onMouseLeave={this.stopArrowScoll}
            Severity: Minor
            Found in src/components/Lookup/index.js and 1 other location - About 55 mins to fix
            src/components/Lookup/index.js on lines 578..584

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

            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

                            <Label
                                label={label}
                                labelAlignment={labelAlignment}
                                hideLabel={hideLabel}
                                required={required}
            Severity: Minor
            Found in src/components/Lookup/index.js and 1 other location - About 55 mins to fix
            src/components/Select/index.js on lines 76..83

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

            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