Grupo-AFAL/frontend-helpers

View on GitHub

Showing 32 of 36 total issues

File shared_form_builder_utils.rb has 275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module FrontendHelpers
module SharedFormBuilderUtils
include BuilderHtmlUtils
 
def label(method, text = nil, options = {}, &block)
Severity: Minor
Found in lib/frontend_helpers/shared_form_builder_utils.rb - About 2 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    moveUp (e) {
    e.preventDefault()
     
    const fieldsContainer1 = e.target.closest(this.fieldsSelectorValue)
    const fieldsContainer2 = previousSibling(
    Severity: Major
    Found in javascript/src/controllers/dynamic-fields-controller.js and 1 other location - About 2 hrs to fix
    javascript/src/controllers/dynamic-fields-controller.js on lines 70..81

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    moveDown (e) {
    e.preventDefault()
     
    const fieldsContainer1 = e.target.closest(this.fieldsSelectorValue)
    const fieldsContainer2 = nextSibling(
    Severity: Major
    Found in javascript/src/controllers/dynamic-fields-controller.js and 1 other location - About 2 hrs to fix
    javascript/src/controllers/dynamic-fields-controller.js on lines 57..68

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export const previousSibling = (element, selector) => {
    let previousElement = element.previousElementSibling
    if (!previousElement) return null
     
    while (!previousElement.matches(selector)) {
    Severity: Major
    Found in javascript/src/utils/domHelpers.js and 1 other location - About 2 hrs to fix
    javascript/src/utils/domHelpers.js on lines 48..58

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export const nextSibling = (element, selector) => {
    let nextElement = element.nextElementSibling
    if (!nextElement) return null
     
    while (!nextElement.matches(selector)) {
    Severity: Major
    Found in javascript/src/utils/domHelpers.js and 1 other location - About 2 hrs to fix
    javascript/src/utils/domHelpers.js on lines 36..46

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    if (this.hasAddTarget) {
    if (this.value === this.maxValue) {
    this.addTarget.classList.add('is-static')
    } else {
    this.addTarget.classList.remove('is-static')
    Severity: Major
    Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 1 hr to fix
    javascript/src/controllers/step-number-input-controller.js on lines 48..54

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    if (this.hasSubtractTarget) {
    if (this.value === this.minValue) {
    this.subtractTarget.classList.add('is-static')
    } else {
    this.subtractTarget.classList.remove('is-static')
    Severity: Major
    Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 1 hr to fix
    javascript/src/controllers/step-number-input-controller.js on lines 40..46

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    connect () {
    if (this.hasOverlayTarget && this.hasContainerTarget) {
    this.overlayTarget.addEventListener('click', this.closeMenu)
    this.containerTarget.addEventListener('click', this.closeMenu)
    }
    Severity: Major
    Found in javascript/src/controllers/side-menu-controller.js and 1 other location - About 1 hr to fix
    javascript/src/controllers/side-menu-controller.js on lines 13..18

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    disconnect () {
    if (this.hasOverlayTarget && this.hasContainerTarget) {
    this.overlayTarget.removeEventListener('click', this.closeMenu)
    this.containerTarget.removeEventListener('click', this.closeMenu)
    }
    Severity: Major
    Found in javascript/src/controllers/side-menu-controller.js and 1 other location - About 1 hr to fix
    javascript/src/controllers/side-menu-controller.js on lines 6..11

    Method step_number_field has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def step_number_field(method, options = {})
    options[:data] ||= {}
    options[:data]['step-number-input-target'] = 'input'
     
    subtract_data = options.delete(:subtract_data) || {}
    Severity: Minor
    Found in lib/frontend_helpers/shared_form_builder_utils.rb - About 1 hr to fix

      Function fillInAddress has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      fillInAddress () {
      const place = this.autocomplete.getPlace()
       
      for (const component of place.address_components) {
      const componentType = component.types[0]
      Severity: Minor
      Found in javascript/src/controllers/autocomplete-address-controller.js - About 1 hr to fix

        Method file_field_group has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def file_field_group(method, options = {})
        options.with_defaults!(
        class: 'file-input',
        data: { action: 'file-input#onChange' }
        )
        Severity: Minor
        Found in lib/frontend_helpers/field_group_builders.rb - About 1 hr to fix

          Method step_number_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def step_number_field(method, options = {})
          options[:data] ||= {}
          options[:data]['step-number-input-target'] = 'input'
           
          subtract_data = options.delete(:subtract_data) || {}
          Severity: Minor
          Found in lib/frontend_helpers/shared_form_builder_utils.rb - About 1 hr to fix

          Function default has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function (options = {}) {
          promise =
          promise ||
          new Promise((resolve, reject) => {
          // Reject the promise after a timeout
          Severity: Minor
          Found in javascript/src/utils/google-maps-loader.js - About 1 hr to fix

            Method time_field has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def time_field(method, options = {})
            options[:wrapper_options] = {
            'data-datepicker-enable-time-value': true,
            'data-datepicker-no-calendar-value': true
            }
            Severity: Minor
            Found in lib/frontend_helpers/shared_form_builder_utils.rb - About 1 hr to fix

              Method slim_select_field has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def slim_select_field(method, values, options = {}, html_options = {})
              html_options.with_defaults!(multiple: false, 'data-slim-select-target': 'select')
               
              options.with_defaults!(
              add_items: false,
              Severity: Minor
              Found in lib/frontend_helpers/shared_form_builder_utils.rb - About 1 hr to fix

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

                setValue () {
                this.value = Math.max(Math.min(this.value, this.maxValue), this.minValue)
                this.inputTarget.value = this.value
                 
                if (this.hasAddTarget) {
                Severity: Minor
                Found in javascript/src/controllers/step-number-input-controller.js - About 45 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                add (e) {
                e.preventDefault()
                this.value += 1
                this.setValue()
                this.triggerChangeEvent()
                Severity: Minor
                Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 45 mins to fix
                javascript/src/controllers/step-number-input-controller.js on lines 29..34

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                subtract (e) {
                e.preventDefault()
                this.value -= 1
                this.setValue()
                this.triggerChangeEvent()
                Severity: Minor
                Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 45 mins to fix
                javascript/src/controllers/step-number-input-controller.js on lines 22..27

                Method switch_field_group has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def switch_field_group(method, options = {},
                checked_value = '1', unchecked_value = '0', &block)
                Severity: Minor
                Found in lib/frontend_helpers/form_builder_helpers/switch_field.rb - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language