nexxtway/react-rainbow

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

Summary

Maintainability
F
3 days
Test Coverage

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

/* eslint-disable react/sort-comp */
/* eslint-disable no-console */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ThemeProvider } from 'styled-components';
Severity: Minor
Found in src/components/Table/index.js - About 7 hrs to fix

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

        render() {
            const {
                id,
                data,
                sortedBy,
    Severity: Major
    Found in src/components/Table/index.js - About 3 hrs to fix

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

          componentDidUpdate(prevProps) {
              const {
                  children: prevChildren,
                  showCheckboxColumn: prevShowCheckboxColumn,
                  maxRowSelection: prevMaxRowSelection,
      Severity: Major
      Found in src/components/Table/index.js - About 2 hrs to fix

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

            constructor(props) {
                super(props);
                const {
                    children,
                    showCheckboxColumn,
        Severity: Minor
        Found in src/components/Table/index.js - About 1 hr to fix

          Function handleSelectRow has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              handleSelectRow(event, isMultiple, rowKeyValue) {
                  const { onRowSelection } = this.props;
                  const { indexes } = this;
                  const { rows } = this.state;
                  const maxRowSelection = this.getMaxRowSelection();
          Severity: Minor
          Found in src/components/Table/index.js - About 1 hr to fix

            Function updateRows has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                updateRows() {
                    const { keyField, selectedRows, onRowSelection, data } = this.props;
                    const maxRowSelection = this.getMaxRowSelection();
                    const newRows = getRows({
                        keyField,
            Severity: Minor
            Found in src/components/Table/index.js - About 1 hr to fix

              Function componentDidUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  componentDidUpdate(prevProps) {
                      const {
                          children: prevChildren,
                          showCheckboxColumn: prevShowCheckboxColumn,
                          maxRowSelection: prevMaxRowSelection,
              Severity: Minor
              Found in src/components/Table/index.js - About 25 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 5 locations. Consider refactoring.
              Open

                      const {
                          children,
                          showCheckboxColumn,
                          showRowNumberColumn,
                          rowNumberOffset,
              Severity: Major
              Found in src/components/Table/index.js and 4 other locations - About 1 hr to fix
              src/components/ButtonGroupPicker/index.js on lines 62..75
              src/components/Lookup/selectedValue.js on lines 61..74
              src/components/RadioGroup/index.js on lines 32..45
              src/components/VisualPicker/index.js on lines 48..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 72.

              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 {
                          children,
                          showCheckboxColumn,
                          keyField,
                          data,
              Severity: Major
              Found in src/components/Table/index.js and 2 other locations - About 1 hr to fix
              src/components/Input/label/index.js on lines 9..21
              src/components/MonthlyCalendar/index.js on lines 19..31

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

              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 updatedRows = getUpdatedRowsWhenDeselect({
                          maxRowSelection,
                          rows,
                          indexes,
                          isMultiple,
              Severity: Major
              Found in src/components/Table/index.js and 1 other location - About 1 hr to fix
              src/components/Table/index.js on lines 313..321

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

              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 updatedRows = getUpdatedRowsWhenSelect({
                              maxRowSelection,
                              rows,
                              indexes,
                              isMultiple,
              Severity: Major
              Found in src/components/Table/index.js and 1 other location - About 1 hr to fix
              src/components/Table/index.js on lines 355..363

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

              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 prevColumns = getColumns({
                          children: prevChildren,
                          showCheckboxColumn: prevShowCheckboxColumn,
                          showRowNumberColumn,
                          rowNumberOffset,
              Severity: Minor
              Found in src/components/Table/index.js and 1 other location - About 35 mins to fix
              src/components/Table/index.js on lines 137..145

              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 currentColumns = getColumns({
                          children,
                          showCheckboxColumn,
                          showRowNumberColumn,
                          rowNumberOffset,
              Severity: Minor
              Found in src/components/Table/index.js and 1 other location - About 35 mins to fix
              src/components/Table/index.js on lines 128..136

              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