wahanegi/vibereport

View on GitHub
app/javascript/components/UI/rich-text/RichInputElement.js

Summary

Maintainability
F
1 wk
Test Coverage

Function RichInputElement has a Cognitive Complexity of 241 (exceeds 5 allowed). Consider refactoring.
Open

const RichInputElement = ({ richText = '',
                           listUsers: listAllUsers,
                           setChosenUsers = ()=>{},
                           onSubmit ,
                           onClose,
Severity: Minor
Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 4 days 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 handleKeyDown has 216 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const handleKeyDown = event => {
    event.preventDefault()
    const selectedValue = window.getSelection().toString();
    const text = element.textContent
    const cursorPos = Cursor.getCurrentCursorPosition(element, initCoordinates)
Severity: Major
Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 1 day to fix

    File RichInputElement.js has 410 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useEffect, useRef, useState} from 'react';
    import Cursor from "../rich-text/cursor";
    import DropDownList from "./DropDownList";
    import {userFullName} from "../../helpers/library";
    import RichText from "./rich-text";
    Severity: Minor
    Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 5 hrs to fix

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

      const clickEnterTabHandling = ( i ) => {
        if ( i === undefined ) {
          setIsDropdownList(false)
          return 0
        }
      Severity: Minor
      Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                      if(userFromNode?.length) {
                        const filtratedUsersByName = RichText.filtrationByName(userFullName(userFromNode[0]), copyChosenUsers)
                        setCopyChosenUsers(filtratedUsersByName)
                        setChosenUsers(filtratedUsersByName)
                        setFilteredUsers(RichText.sortUsersByFullName([...filteredUsers, userFromNode[0]]))
        Severity: Major
        Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  } else if (listFoundUsers.length) {
                    //delete user from text, Users, ChosenUsers and put instead of it char
          
                    const userToDel = RichText.contentBtwTags(textHTML, cursorPos, END_TAG_AT, 1)
                    const decrementedNumberChosenUsers = copyChosenUsers.filter(user => userFullName(user) !== userToDel) // delete user from chosenUsers
          Severity: Major
          Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if (copyChosenUsers.find(user => userFullName(user) === newSearchString))
                        return 0
            Severity: Major
            Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (isBtwSpecialSmb) {
                          RichText.pasteNodeToHTMLobj( MARKER, textHTML, cursorPos, setTextHTML, setCaret, TAG_AT.slice(0, -1), END_TAG_AT )
                          setIsDropdownList(true)
                          setCoordinates(cursorPos.coordinates)
                          return 0
              Severity: Major
              Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        if (listAllUsers.find(user => userFullName(user) === nameUserToDel) && !char.match(/[@<>]/)
                            && nameUserToDel.length === cursorPos.focusOffset - 1) {
                          //if user have in the ListUsers  and cursor at the end of firstLastName of user
                          //then dropdown turn off and put chars in the DIV after endTag
                
                
                Severity: Major
                Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 45 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return 0
                  Severity: Major
                  Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              return
                    Severity: Major
                    Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return 0
                      Severity: Major
                      Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return 0
                        Severity: Major
                        Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return 0
                          Severity: Major
                          Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                      || RichText.contentBtwTags(textHTML, cursorPos, END_TAG_AT, 1).length !== cursorPos.focusOffset-1) return 0
                            Severity: Major
                            Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return 0
                              Severity: Major
                              Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return 0
                                Severity: Major
                                Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          if (indexOfSelection === -1 ) return
                                  Severity: Major
                                  Found in app/javascript/components/UI/rich-text/RichInputElement.js - About 30 mins to fix

                                    There are no issues that match your filters.

                                    Category
                                    Status