nadbm/react-datasheet

View on GitHub

Showing 73 of 73 total issues

File DataSheet.js has 691 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Sheet from './Sheet';
import Row from './Row';
import Cell from './Cell';
Severity: Major
Found in src/DataSheet.js - About 1 day to fix

    DataSheet has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class DataSheet extends PureComponent {
      constructor(props) {
        super(props);
        this.onMouseDown = this.onMouseDown.bind(this);
        this.onMouseUp = this.onMouseUp.bind(this);
    Severity: Minor
    Found in src/DataSheet.js - About 4 hrs to fix

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

        render() {
          const {
            sheetRenderer: SheetRenderer,
            rowRenderer: RowRenderer,
            cellRenderer,
      Severity: Major
      Found in src/DataSheet.js - About 3 hrs to fix

        Function handleCopy has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          handleCopy(e) {
            if (isEmpty(this.state.editing)) {
              e.preventDefault();
              const { dataRenderer, valueRenderer, data } = this.props;
              const { start, end } = this.getState();
        Severity: Minor
        Found in src/DataSheet.js - About 2 hrs 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

        Function _setState has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          _setState(state) {
            const { editModeChanged } = this.props;
            if (editModeChanged && state.editing) {
              const wasEditing = !isEmpty(this.state.editing);
              const wilBeEditing = !isEmpty(state.editing);
        Severity: Minor
        Found in src/DataSheet.js - About 2 hrs 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

        Function handleKey has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          handleKey(e) {
            if (e.isPropagationStopped && e.isPropagationStopped()) {
              return;
            }
            const keyCode = e.which || e.keyCode;
        Severity: Minor
        Found in src/DataSheet.js - About 2 hrs 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

        Function handlePaste has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          handlePaste(e) {
            if (isEmpty(this.state.editing)) {
              let { start, end } = this.getState();
        
              start = { i: Math.min(start.i, end.i), j: Math.min(start.j, end.j) };
        Severity: Major
        Found in src/DataSheet.js - About 2 hrs to fix

          Function searchForNextSelectablePos has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            searchForNextSelectablePos(isCellNavigable, data, start, offsets, jumpRow) {
              const previousRow = location => ({
                i: location.i - 1,
                j: data[0].length - 1,
              });
          Severity: Major
          Found in src/DataSheet.js - About 2 hrs to fix

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

              render() {
                const {
                  row,
                  col,
                  cell,
            Severity: Minor
            Found in src/DataCell.js - About 1 hr to fix

              Function handlePaste has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                handlePaste(e) {
                  if (isEmpty(this.state.editing)) {
                    let { start, end } = this.getState();
              
                    start = { i: Math.min(start.i, end.i), j: Math.min(start.j, end.j) };
              Severity: Minor
              Found in src/DataSheet.js - About 1 hr 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

              Function handleKeyboardCellMovement has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                handleKeyboardCellMovement(e, commit = false) {
                  const { start, editing } = this.getState();
                  const { data } = this.props;
                  const isEditing = editing && !isEmpty(editing);
                  const currentCell = data[start.i] && data[start.i][start.j];
              Severity: Minor
              Found in src/DataSheet.js - About 1 hr 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

              Function handleKey has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                handleKey(e) {
                  if (e.isPropagationStopped && e.isPropagationStopped()) {
                    return;
                  }
                  const keyCode = e.which || e.keyCode;
              Severity: Minor
              Found in src/DataSheet.js - About 1 hr to fix

                Function handleCopy has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  handleCopy(e) {
                    if (isEmpty(this.state.editing)) {
                      e.preventDefault();
                      const { dataRenderer, valueRenderer, data } = this.props;
                      const { start, end } = this.getState();
                Severity: Minor
                Found in src/DataSheet.js - About 1 hr to fix

                  Function handleComponentKey has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    handleComponentKey(e) {
                      // handles keyboard events when editing components
                      const keyCode = e.which || e.keyCode;
                      if (![ENTER_KEY, ESCAPE_KEY, TAB_KEY].includes(keyCode)) {
                        return;
                  Severity: Minor
                  Found in src/DataSheet.js - About 1 hr 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

                  Function searchForNextSelectablePos has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    searchForNextSelectablePos(isCellNavigable, data, start, offsets, jumpRow) {
                      const previousRow = location => ({
                        i: location.i - 1,
                        j: data[0].length - 1,
                      });
                  Severity: Minor
                  Found in src/DataSheet.js - About 1 hr 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

                    handleMouseDown(e) {
                      const { row, col, onMouseDown, cell } = this.props;
                      if (!cell.disableEvents) {
                        onMouseDown(row, col, e);
                      }
                  Severity: Major
                  Found in src/DataCell.js and 1 other location - About 1 hr to fix
                  src/DataCell.js on lines 126..131

                  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

                    handleContextMenu(e) {
                      const { row, col, onContextMenu, cell } = this.props;
                      if (!cell.disableEvents) {
                        onContextMenu(e, row, col);
                      }
                  Severity: Major
                  Found in src/DataCell.js and 1 other location - About 1 hr to fix
                  src/DataCell.js on lines 105..110

                  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

                    handleDoubleClick(e) {
                      const { row, col, onDoubleClick, cell } = this.props;
                      if (!cell.disableEvents) {
                        onDoubleClick(row, col);
                      }
                  Severity: Major
                  Found in src/DataCell.js and 1 other location - About 1 hr to fix
                  src/DataCell.js on lines 112..117

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

                  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

                    handleMouseOver(e) {
                      const { row, col, onMouseOver, cell } = this.props;
                      if (!cell.disableEvents) {
                        onMouseOver(row, col);
                      }
                  Severity: Major
                  Found in src/DataCell.js and 1 other location - About 1 hr to fix
                  src/DataCell.js on lines 119..124

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

                  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

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

                    render() {
                      const {
                        cell,
                        row,
                        col,
                  Severity: Minor
                  Found in src/Cell.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language