cellog/react-selection

View on GitHub

Showing 37 of 37 total issues

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

  selectItem(idx) {
    // first check to see if this index is the same type as the first node selected
    const node = this.nodes[idx]
    if (!node.selectable) return
    if (this.props.hasOwnProperty('acceptedTypes')) {
Severity: Minor
Found in src/selectedList.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

Avoid too many return statements within this function.
Open

  return true
Severity: Major
Found in src/shallowEqualScalar.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return false
    Severity: Major
    Found in src/shallowEqualScalar.js - About 30 mins to fix

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

      export default function shallowEqual(objA, objB) {
        if (objA === objB) {
          return true
        }
      
      
      Severity: Minor
      Found in src/shallowEqual.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

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

        testNodes({ selectionRectangle, props, findit, mouse }, node, idx) {
          let bounds
          if (node.bounds) {
            bounds = node.bounds
          } else {
      Severity: Minor
      Found in src/selectedList.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

      Unable to resolve path to module 'react-dom'.
      Open

      import { findDOMNode } from 'react-dom'
      Severity: Minor
      Found in src/SelectionManager.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Unable to resolve path to module 'react-dom'.
      Open

      import { findDOMNode } from 'react-dom'
      Severity: Minor
      Found in src/Selection.jsx by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Expected to return a value at the end of this method.
      Open

        cancelSelection({ indices, nodes }) {
      Severity: Minor
      Found in src/SelectionManager.js by eslint

      Require Consistent Returns (consistent-return)

      One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function's return value.

      Unlike statically-typed languages that will catch when a function doesn't return the type of data expected, JavaScript has no such checks, meaning that it's easy to make mistakes such as this:

      function doSomething(condition) {
      
          if (condition) {
              return true;
          } else {
              return;
          }
      }

      Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

      Rule Details

      This rule is aimed at ensuring all return statements either specify a value or don't specify a value.

      It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

      Examples of incorrect code for this rule:

      /*eslint consistent-return: "error"*/
      
      function doSomething(condition) {
      
          if (condition) {
              return true;
          } else {
              return;
          }
      }
      
      function doSomething(condition) {
      
          if (condition) {
              return;
          } else {
              return true;
          }
      }
      
      function doSomething(condition) {
      
          if (condition) {
              return true;
          }
      }

      Examples of correct code for this rule:

      /*eslint consistent-return: "error"*/
      
      function doSomething(condition) {
      
          if (condition) {
              return true;
          } else {
              return false;
          }
      }
      
      function Foo() {
          if (!(this instanceof Foo)) {
              return new Foo();
          }
      
          this.a = 0;
      }

      When Not To Use It

      If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule. Source: http://eslint.org/docs/rules/

      Unable to resolve path to module 'react'.
      Open

      import React, { PropTypes } from 'react'
      Severity: Minor
      Found in src/Selectable.jsx by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Component should be written as a pure function
      Open

        return class extends React.Component {
      Severity: Minor
      Found in src/ReferenceableContainer.jsx by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Arrow function used ambiguously with a conditional expression.
      Open

          newSelected.forEach(idx => prevSelected.indexOf(idx) === -1 ?
      Severity: Minor
      Found in src/selectedList.js by eslint

      Disallow arrow functions where they could be confused with comparisons (no-confusing-arrow)

      Arrow functions (=>) are similar in syntax to some comparison operators (>, <, <=, and >=). This rule warns against using the arrow function syntax in places where it could be confused with a comparison operator. Even if the arguments of the arrow function are wrapped with parens, this rule still warns about it unless allowParens is set to true.

      Here's an example where the usage of => could be confusing:

      // The intent is not clear
      var x = a => 1 ? 2 : 3;
      // Did the author mean this
      var x = function (a) { return 1 ? 2 : 3 };
      // Or this
      var x = a <= 1 ? 2 : 3;

      Rule Details

      The following patterns are considered warnings:

      /*eslint no-confusing-arrow: "error"*/
      /*eslint-env es6*/
      
      var x = a => 1 ? 2 : 3;
      var x = (a) => 1 ? 2 : 3;
      var x = (a) => (1 ? 2 : 3);

      The following patterns are not considered warnings:

      /*eslint no-confusing-arrow: "error"*/
      /*eslint-env es6*/
      
      var x = a => { return 1 ? 2 : 3; };
      var x = (a) => { return 1 ? 2 : 3; };

      Options

      This rule accepts a single options argument with the following defaults:

      {
          "rules": {
              "no-confusing-arrow": ["error", {"allowParens": false}]
          }
      }

      allowParens is a boolean setting that can be true or false:

      1. true relaxes the rule and accepts parenthesis as a valid "confusion-preventing" syntax.
      2. false warns even if the expression is wrapped in parenthesis

      When allowParens is set to true following patterns are no longer considered as warnings:

      /*eslint no-confusing-arrow: ["error", {allowParens: true}]*/
      /*eslint-env es6*/
      var x = a => (1 ? 2 : 3);
      var x = (a) => (1 ? 2 : 3);

      Related Rules

      Unable to resolve path to module 'react-dom'.
      Open

      import { findDOMNode } from 'react-dom'
      Severity: Minor
      Found in src/selectedList.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Expected to return a value at the end of this method.
      Open

        static getCoordinates(e, id, con = console) {
      Severity: Minor
      Found in src/mouseMath.js by eslint

      Require Consistent Returns (consistent-return)

      One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function's return value.

      Unlike statically-typed languages that will catch when a function doesn't return the type of data expected, JavaScript has no such checks, meaning that it's easy to make mistakes such as this:

      function doSomething(condition) {
      
          if (condition) {
              return true;
          } else {
              return;
          }
      }

      Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

      Rule Details

      This rule is aimed at ensuring all return statements either specify a value or don't specify a value.

      It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

      Examples of incorrect code for this rule:

      /*eslint consistent-return: "error"*/
      
      function doSomething(condition) {
      
          if (condition) {
              return true;
          } else {
              return;
          }
      }
      
      function doSomething(condition) {
      
          if (condition) {
              return;
          } else {
              return true;
          }
      }
      
      function doSomething(condition) {
      
          if (condition) {
              return true;
          }
      }

      Examples of correct code for this rule:

      /*eslint consistent-return: "error"*/
      
      function doSomething(condition) {
      
          if (condition) {
              return true;
          } else {
              return false;
          }
      }
      
      function Foo() {
          if (!(this instanceof Foo)) {
              return new Foo();
          }
      
          this.a = 0;
      }

      When Not To Use It

      If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule. Source: http://eslint.org/docs/rules/

      Unable to resolve path to module 'react'.
      Open

      import React, { PropTypes } from 'react'
      Severity: Minor
      Found in src/Selection.jsx by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Unable to resolve path to module 'react-dom'.
      Open

      import { findDOMNode } from 'react-dom'
      Severity: Minor
      Found in src/InputManager.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Unable to resolve path to module 'react'.
      Open

      import React, { PropTypes } from 'react'
      Severity: Minor
      Found in src/ReferenceableContainer.jsx by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Unable to resolve path to module 'babel-register'.
      Open

      require('babel-register')
      Severity: Minor
      Found in karma-common.conf.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Severity
      Category
      Status
      Source
      Language