dowjones/react-dropdown-tree-select

View on GitHub

Showing 67 of 71 total issues

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

/*!
 * React Dropdown Tree Select
 * A lightweight, fast and highly customizable tree select component.
 * Hrusikesh Panda <hrusikesh.panda@dowjones.com>
 * Copyright (c) 2017 Dow Jones, Inc. <support@dowjones.com> (http://dowjones.com)
Severity: Minor
Found in src/index.js - About 3 hrs to fix

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

      render() {
        const { disabled, readOnly, mode, texts, inlineSearchInput, tabIndex } = this.props
        const { showDropdown, currentFocus, tags } = this.state
    
        const activeDescendant = currentFocus ? `${currentFocus}_li` : undefined
    Severity: Major
    Found in src/index.js - About 2 hrs to fix

      Function setNodeCheckedState has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        setNodeCheckedState(id, checked) {
          // radioSelect must be done before setting node checked, to avoid conflicts with partialCheckParents
          // this only occurs when selecting the parent of a previously selected child when the parent also has a parent
          if (this.radioSelect) this.togglePreviousChecked(id, checked)
      
      
      Severity: Minor
      Found in src/tree-manager/index.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

        const {
          keepTreeOnSearch,
          keepChildrenOnSearch,
          _children,
          matchInChildren,
      Severity: Major
      Found in src/tree-node/index.js and 1 other location - About 1 hr to fix
      src/tree/index.js on lines 74..88

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

      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

        static propTypes = {
          title: PropTypes.string,
          text: PropTypes.string,
          className: PropTypes.string,
          actionData: PropTypes.object,
      Severity: Minor
      Found in src/tree-node/action.js and 1 other location - About 30 mins to fix
      src/tags/index.js on lines 30..37

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

      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

        static propTypes = {
          tags: PropTypes.array,
          onTagRemove: PropTypes.func,
          readOnly: PropTypes.bool,
          disabled: PropTypes.bool,
      Severity: Minor
      Found in src/tags/index.js and 1 other location - About 30 mins to fix
      src/tree-node/action.js on lines 5..12

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

      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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        render() {
          const { mode, title, label, id, partial, checked } = this.props
          const { value, disabled, showPartiallySelected, readOnly, clientId } = this.props
          const nodeLabelProps = { className: 'node-label' }
      
      
      Severity: Minor
      Found in src/tree-node/node-label.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        render() {
          const { id, label, labelRemove = 'Remove', readOnly, disabled } = this.props
      
          const tagId = getTagId(id)
          const buttonId = `${id}_button`
      Severity: Minor
      Found in src/tag/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

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

      function findIndex(arr, predicate, thisArg) {
        // if native support is available, ship it off
        if (Array.prototype.findIndex) {
          return arr.findIndex(predicate, thisArg)
        }
      Severity: Minor
      Found in src/utils/findIndex.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

      Replace e with (e)
      Open

        handleClick = e => {
      Severity: Minor
      Found in src/tag/index.js by eslint

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

      Replace t with (t)
      Open

            tags.forEach(t => {
      Severity: Minor
      Found in src/trigger/index.js by eslint

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

      Replace el with (el)
      Open

              inputRef={el => {
      Severity: Minor
      Found in src/index.js by eslint

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

      Replace n with (n)
      Open

            let focusIndex = findIndex(this.allVisibleNodes, n => n.key === currentId) + 1
      Severity: Minor
      Found in src/tree/index.js by eslint

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

      Replace e with (e)
      Open

        onToggle = e => {
      Severity: Minor
      Found in src/tree-node/toggle.js by eslint

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

      Replace e with (e)
      Open

        onKeyUp = e => {
      Severity: Minor
      Found in src/tag/index.js by eslint

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

      Replace (m with ((m)
      Open

          matches.forEach(m => {
      Severity: Minor
      Found in src/tree-manager/index.js by eslint

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

      Replace node with (node)
      Open

          this.tree.forEach(node => {
      Severity: Minor
      Found in src/tree-manager/index.js by eslint

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

      Replace nextProps with (nextProps)
      Open

        UNSAFE_componentWillReceiveProps = nextProps => {
      Severity: Minor
      Found in src/tree/index.js by eslint

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

      Replace c with (c)
      Open

          node._children.forEach(c => markSubTreeVisited(getItemById(c), visited, getItemById))
      Severity: Minor
      Found in src/tree-manager/nodeVisitor.js by eslint

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

      Replace e with (e)
      Open

        handleTrigger = e => {
      Severity: Minor
      Found in src/trigger/index.js by eslint

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

      Severity
      Category
      Status
      Source
      Language