wahanegi/vibereport

View on GitHub

Showing 56 of 274 total issues

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

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

import React from 'react';
  import { render, fireEvent , screen } from '@testing-library/react';
import RichInputElement from "../UI/rich-text/RichInputElement";
import Cursor from "../UI/rich-text/cursor";
import  RichText  from "../UI/rich-text/rich-text"
Severity: Major
Found in app/javascript/components/__tests__/RichInputElement.test.js - About 1 day to fix

    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

      Function getCurrentCursorPosition has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

          static getCurrentCursorPosition(parentElement, initCoord = {x: 0, y: 0}) {
              if(window.getSelection()) {
                  const selection = window.getSelection()
                  let charCount = -1
                  let focusNode = null
      Severity: Minor
      Found in app/javascript/components/UI/rich-text/cursor.js - About 7 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

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

        const MemeSelection = ({data, setData, saveDataToDb, steps, service, isCustomGif, setIsCustomGif, draft}) => {
          const {emotion, api_giphy_key, response} = data
          const navigate = useNavigate()
          const {isLoading, error} = service
          const [gifUrl, setGifUrl] = useState(response.attributes.gif || {})
        Severity: Minor
        Found in app/javascript/components/Pages/MemeSelection.js - About 3 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

        Function Results has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        const Results = ({data, setData, steps = data.response.attributes.steps || [], draft = true}) => {
          const [loaded, setLoaded] = useState(false)
          const [results, setResults] = useState( {})
          const {answers, emotions, fun_question, gifs, sent_shoutouts, received_shoutouts,
                current_user_shoutouts, responses_count, received_and_public_shoutouts, prev_results_path} = results
        Severity: Minor
        Found in app/javascript/components/Pages/ResultsPage/index.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

        Function _createRange has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            static _createRange(node, chars, range) {
                if (!range) {
                    range = document.createRange()
                    range.selectNode(node);
                    range.setStart(node, 0);
        Severity: Minor
        Found in app/javascript/components/UI/rich-text/cursor.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

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

        const App = () => {
          const mainPage = 'emotion-selection-web'
          const [error, setError] = useState('')
          const [frontDatabase, setFrontDatabase] = useState(initDB)
          const [isLoading, setIsLoading] = useState(false)
        Severity: Major
        Found in app/javascript/components/App.js - About 2 hrs to fix

          Function getCurrentCursorPosition has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static getCurrentCursorPosition(parentElement, initCoord = {x: 0, y: 0}) {
                  if(window.getSelection()) {
                      const selection = window.getSelection()
                      let charCount = -1
                      let focusNode = null
          Severity: Major
          Found in app/javascript/components/UI/rich-text/cursor.js - About 2 hrs to fix

            RichText has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export default class RichText {
              
              static filtrationById = ( separatorArr, mainArr ) => {
                if ( !separatorArr?.length ) {return mainArr}
                return mainArr.filter(item=> !separatorArr.some(({ id }) => id === item.id))
            Severity: Minor
            Found in app/javascript/components/UI/rich-text/rich-text.js - About 2 hrs to fix

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

              const IcebreakerAnswer = ({data, setData, saveDataToDb, steps, service, draft}) => {
                const {isLoading, error} = service
                const [loaded, setLoaded] = useState(false)
                const [prevStateAnswer, setPrevStateAnswer] = useState( {})
                const [answerFunQuestion, setAnswerFunQuestion] = useState( {})
              Severity: Minor
              Found in app/javascript/components/Pages/IcebreakerAnswer.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

              Function EmotionIndex has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              const EmotionIndex = ({ teams, nextTimePeriod, isMinUsersResponses }) => {
              
                function getDataForTeam(team) {
                  const emotionData = {
                    name: team.name,
              Severity: Minor
              Found in app/javascript/components/Pages/ResultsPageManager/EmotionIndex.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

              Function ResultsManager has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              const ResultsManager = ({data, setData, steps = data.response.attributes.steps || [], draft = true}) => {
                const [loaded, setLoaded] = useState(false)
                const [results, setResults] = useState( {})
                const {emotions, responses_count, teams, prev_results_path} = results
                const {time_periods, time_period, current_user} = data
              Severity: Minor
              Found in app/javascript/components/Pages/ResultsPageManager/index.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

              Function ModalOverlay has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const ModalOverlay = () =>{
                  const  idEditText =  isEmpty(editObj) ? null : editObj.id
              
                  const submitHandling = ({richText, chosenUsers, isPublic}) => {
                    const dataSend = {
              Severity: Minor
              Found in app/javascript/components/UI/ShoutoutModal.js - About 1 hr to fix

                Function NavigationBar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                const NavigationBar = ({timePeriod, showPrevTimePeriod, showNextTimePeriod, time_periods, prevTimePeriod,
                                        nextTimePeriod, steps, emotions, data, setShowWorkingModal, setData}) => {
                  if(isEmpty(time_periods)) return null;
                
                  const notWorking = data.response.attributes.not_working
                Severity: Minor
                Found in app/javascript/components/Pages/ResultsPage/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 ShoutoutModal has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                const ShoutoutModal = ({ onClose, data, setData: setDataInDB, editObj = {} }) => {
                  const [isNotAlert, setIsNotAlert] = useState(true)
                  const [errorMessage, setErrorMessage] = useState("")
                  const [richText, setRichText] = useState(isEmpty(editObj) ? '' : editObj.rich_text)
                
                
                Severity: Minor
                Found in app/javascript/components/UI/ShoutoutModal.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 EmotionIntensity has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                const EmotionIntensity = ({data, setData, saveDataToDb, steps, service, draft}) => {
                  const {isLoading, error} = service
                  const { word, category } = data.emotion
                  const gif_url = data.response.attributes.gif?.src
                  const [rating, setRating] = useState(data.response.attributes.rating || null);
                Severity: Minor
                Found in app/javascript/components/Pages/EmotionIntensity.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 41 lines of code (exceeds 25 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 1 hr to fix

                  Function IcebreakerQuestion has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const IcebreakerQuestion = ({data, setData, saveDataToDb, steps, service, draft}) => {
                    const {isLoading, error} = service
                    const [loaded, setLoaded] = useState(false)
                    const [prevStateQuestion, setPrevStateQuestion] = useState({})
                    const [funQuestion, setFunQuestion] = useState( {})
                  Severity: Minor
                  Found in app/javascript/components/Pages/IcebreakerQuestion.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

                  Severity
                  Category
                  Status
                  Source
                  Language