nadbm/react-datasheet

View on GitHub

Showing 25 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

                  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

                    Function handleNavigate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      handleNavigate(e, offsets, jumpRow) {
                        if (offsets && (offsets.i || offsets.j)) {
                          const { data } = this.props;
                          const { start } = this.getState();
                    
                    
                    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 constructor has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      constructor(props) {
                        super(props);
                        this.onMouseDown = this.onMouseDown.bind(this);
                        this.onMouseUp = this.onMouseUp.bind(this);
                        this.onMouseOver = this.onMouseOver.bind(this);
                    Severity: Minor
                    Found in src/DataSheet.js - About 1 hr to fix

                      Function onMouseDown has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        onMouseDown(i, j, e) {
                          const isNowEditingSameCell =
                            !isEmpty(this.state.editing) &&
                            this.state.editing.i === i &&
                            this.state.editing.j === j;
                      Severity: Minor
                      Found in src/DataSheet.js - About 1 hr to fix

                        Function handleKeyboardCellMovement has 26 lines of code (exceeds 25 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
                          Severity
                          Category
                          Status
                          Source
                          Language