prakhar1989/react-tags

View on GitHub

Showing 12 of 18 total issues

File ReactTags.js has 501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { Component, createRef } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import isEqual from 'lodash/isEqual';
import noop from 'lodash/noop';
Severity: Major
Found in src/components/ReactTags.js - About 1 day to fix

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

      render() {
        const tagItems = this.getTagItems();
        const classNames = { ...DEFAULT_CLASSNAMES, ...this.props.classNames };
    
        // get the suggestions for the given query
    Severity: Major
    Found in src/components/ReactTags.js - About 3 hrs to fix

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

        handleKeyDown(e) {
          const { query, selectedIndex, suggestions, selectionMode } = this.state;
      
          // hide suggestions menu on escape
          if (e.keyCode === KEYS.ESCAPE) {
      Severity: Minor
      Found in src/components/ReactTags.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

      ReactTags has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ReactTags extends Component {
        static propTypes = {
          placeholder: PropTypes.string,
          labelField: PropTypes.string,
          suggestions: PropTypes.arrayOf(
      Severity: Minor
      Found in src/components/ReactTags.js - About 2 hrs to fix

        Function App has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const App = () => {
          const [tags, setTags] = React.useState([
            { id: 'Thailand', text: 'Thailand' },
            { id: 'India', text: 'India' },
            { id: 'Vietnam', text: 'Vietnam' },
        Severity: Major
        Found in example/main.js - About 2 hrs to fix

          Function Tag has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const Tag = (props) => {
            const tagRef = useRef(null);
            const { readOnly, tag, classNames, index } = props;
          
            const [{ isDragging }, drag] = useDrag(() => ({
          Severity: Minor
          Found in src/components/Tag.js - About 1 hr to fix

            Function handleKeyDown has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              handleKeyDown(e) {
                const { query, selectedIndex, suggestions, selectionMode } = this.state;
            
                // hide suggestions menu on escape
                if (e.keyCode === KEYS.ESCAPE) {
            Severity: Minor
            Found in src/components/ReactTags.js - About 1 hr to fix

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

              const RemoveComponent = (props) => {
                const { readOnly, removeComponent, onRemove, className, tag, index } = props;
              
                const onKeydown = (event) => {
                  if (KEYS.ENTER.includes(event.keyCode) || event.keyCode === KEYS.SPACE) {
              Severity: Minor
              Found in src/components/RemoveComponent.js - About 1 hr to fix

                Function handleDelete has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  handleDelete(index, event) {
                    event.preventDefault();
                    event.stopPropagation();
                    const currentTags = this.props.tags.slice();
                    // Early exit from the function if the array
                Severity: Minor
                Found in src/components/ReactTags.js - About 1 hr to fix

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

                    render() {
                      const { props } = this;
                  
                      const suggestions = props.suggestions.map(
                        function(item, i) {
                  Severity: Minor
                  Found in src/components/Suggestions.js - About 1 hr to fix

                    Function handleDelete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      handleDelete(index, event) {
                        event.preventDefault();
                        event.stopPropagation();
                        const currentTags = this.props.tags.slice();
                        // Early exit from the function if the array
                    Severity: Minor
                    Found in src/components/ReactTags.js - About 35 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 RemoveComponent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const RemoveComponent = (props) => {
                      const { readOnly, removeComponent, onRemove, className, tag, index } = props;
                    
                      const onKeydown = (event) => {
                        if (KEYS.ENTER.includes(event.keyCode) || event.keyCode === KEYS.SPACE) {
                    Severity: Minor
                    Found in src/components/RemoveComponent.js - About 35 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

                    Severity
                    Category
                    Status
                    Source
                    Language