wahanegi/vibereport

View on GitHub

Showing 56 of 274 total issues

Function AnswerItem has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const AnswerItem = ({answer, emojis, user, current_user, nextTimePeriod, fun_question, answersArray, setAnswersArray}) => {
  const isCurrentUser = !nextTimePeriod && current_user.email === user.email
  const [edit, setEdit] = useState(false)
  const [answerBody, setAnswerBody] = useState(answer.answer_body || '')
  const [showEmojiPicker, setShowEmojiPicker] = useState(false);
Severity: Minor
Found in app/javascript/components/Pages/ResultsPage/QuestionSection.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 NavigationBar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const NavigationBar = ({timePeriod, showPrevTimePeriod, showNextTimePeriod, time_periods, prevTimePeriod,
                        nextTimePeriod, steps, emotions, data, setShowWorkingModal, setData, prev_results_path}) => {
  if(isEmpty(time_periods)) return null;

  const notWorking = data.response.attributes.not_working
Severity: Minor
Found in app/javascript/components/Pages/ResultsPageManager/NavigationBar.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 Results has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const Results = ({ data, setData, steps, hidden = false }) => {
  const [showResults, setShowResults] = useState(false);
  const navigate = useNavigate()
  const slug = useParams().slug

Severity: Minor
Found in app/javascript/components/UI/ShareContent.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 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

    Function EmptyQuestionSection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    const EmptyQuestionSection = ({nextTimePeriod, userName, fun_question,
                                   setShowWorkingModal, data, setData}) => {
      const [text, setText] = useState('');
      const [addClass, setAddClass] = useState('')
      const handleMouseEnter = () => {
    Severity: Minor
    Found in app/javascript/components/Pages/ResultsPage/QuestionSection.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 ListItem has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const ListItem = ( props ) => {
      const ref = useRef(null);
      useEffect(() => {
        if (props.focus) {
          ref.current?.focus();
    Severity: Minor
    Found in app/javascript/components/UI/rich-text/ListItem.js - About 55 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 ProductivityCheckLow has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const ProductivityCheckLow = ({data, setData, saveDataToDb, steps, service, draft}) => {
      const {isLoading, error} = service
      const [productivity, setProductivity] = useState(data.response.attributes.productivity || 0);
      const [isDraft, setIsDraft] = useState(draft);
    
    
    Severity: Minor
    Found in app/javascript/components/Pages/ProductivityCheckLow.js - About 55 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

    Method text_for_waiting has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def text_for_waiting(is_manager, teams_with_managers, managers, time_period)
        if is_manager && teams_with_managers.any?
          "The #{teams_with_managers.pluck(:name).to_sentence} #{'team'.pluralize(teams_with_managers.count)} " \
            "#{teams_with_managers.count == 1 ? 'is' : 'are'} waiting for you to check-in for #{time_period.date_range_str}"
        elsif managers.any?
    Severity: Minor
    Found in app/helpers/user_email_mailer_helper.rb - About 55 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 deeply nested control flow statements.
    Open

                            if (node === parentElement) {
                                break;
                            }
    Severity: Major
    Found in app/javascript/components/UI/rich-text/cursor.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (node.previousSibling) {
                                  node = node.previousSibling;
                                  charCount += node.textContent.length;
                                  realPos +=
                                      (node.outerHTML === undefined ? RichText.encodeSpace(RichText.decodeSpace160(node.textContent)) : node.outerHTML).length
      Severity: Major
      Found in app/javascript/components/UI/rich-text/cursor.js - About 45 mins 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

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

          const removeEmoji = (emojiObject, emojisArr, setEmojisArr, setSelectedEmoji, current_user, setEmojiObject) => {
            axios.delete(`/api/v1/emojis/${emojiObject.id}`)
              .then(res => {
                if (res.data.message !== 'success') return;
          
          
          Severity: Minor
          Found in app/javascript/components/Pages/ResultsPage/Emojis/EmojiPicker.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 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

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

                   const calculatePickerPosition = (inputRef, showEmojiPicker, setPickerPosition) => {
                    useEffect(() => {
                      if (inputRef.current && showEmojiPicker) {
                        const inputRect = inputRef.current.getBoundingClientRect();
                        const screenHeight = window.innerHeight;
                  Severity: Minor
                  Found in app/javascript/components/Pages/ResultsPage/Emojis/EmojiRow.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

                  Consider simplifying this complex logical expression.
                  Open

                        if (str[cursorPosition] === "&" && str[cursorPosition + 1] === "n" && str[cursorPosition + 2] === "b"
                            && str[cursorPosition + 3] === "s" && str[cursorPosition + 4] === "p" && str[cursorPosition + 5] === ";") {
                          str = str.slice(0, cursorPosition) + str.slice(cursorPosition + 6);
                        } else {
                          str = str.slice(0, cursorPosition) + str.slice(cursorPosition + 1);
                  Severity: Major
                  Found in app/javascript/components/UI/rich-text/rich-text.js - About 40 mins to fix

                    Method btn_special has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def btn_special(word, attr)
                        case attr
                        when :width
                          word.length > 11 ? word.length * 11 : 127
                        when :margin
                    Severity: Minor
                    Found in app/helpers/user_email_mailer_helper.rb - 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

                    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
                      Severity
                      Category
                      Status
                      Source
                      Language