programandoarg/pg_rails

View on GitHub
pg_associable/app/javascript/asociable_controller.tsx

Summary

Maintainability
C
1 day
Test Coverage

Function connect has a Cognitive Complexity of 34 (exceeds 7 allowed). Consider refactoring.
Confirmed

  connect () {
    // ID Ășnico para identificar el campo y el modal
    this.elemId = Math.trunc(Math.random() * 1000000000)

    this.input = this.element.querySelector('input[type=text]')
Severity: Minor
Found in pg_associable/app/javascript/asociable_controller.tsx - About 4 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 connect has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

  connect () {
    // ID Ășnico para identificar el campo y el modal
    this.elemId = Math.trunc(Math.random() * 1000000000)

    this.input = this.element.querySelector('input[type=text]')
Severity: Major
Found in pg_associable/app/javascript/asociable_controller.tsx - About 3 hrs to fix

    File asociable_controller.tsx has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Wontfix

    import { Controller } from '@hotwired/stimulus'
    import * as React from 'react'
    import { renderToStaticMarkup } from 'react-dom/server'
    
    export default class extends Controller {
    Severity: Minor
    Found in pg_associable/app/javascript/asociable_controller.tsx - About 2 hrs to fix

      Function doSearch has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

        doSearch (force = false) {
          if (this.element.classList.contains('filled')) {
            return
          }
          if (!force && this.input.value.length < 3) {
      Severity: Minor
      Found in pg_associable/app/javascript/asociable_controller.tsx - About 1 hr to fix

        Function resetResultados has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Confirmed

          resetResultados () {
            this.lastValue = null
            const rows = []
            if (this.element.dataset.puedeCrear) {
              rows.push(
        Severity: Minor
        Found in pg_associable/app/javascript/asociable_controller.tsx - About 1 hr to fix

          Function setMaxHeight has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Confirmed

            setMaxHeight () {
              let maxHeight
              if (!this.element.closest('.modal')) {
                const scrollTop = document.scrollingElement.scrollTop
                const inputY = this.input.getBoundingClientRect().bottom + scrollTop
          Severity: Minor
          Found in pg_associable/app/javascript/asociable_controller.tsx - 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

          There are no issues that match your filters.

          Category
          Status