programandoarg/pg_rails

View on GitHub

Showing 25 of 30 total issues

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 simple_form_bootstrap.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    SimpleForm.setup do |config|
      # Default class for buttons
      config.button_class = 'btn'
    
      # Define the default class of the input wrapper of the boolean input.
    Severity: Minor
    Found in pg_engine/config/simple_form/simple_form_bootstrap.rb - About 3 hrs to fix

      Method encabezado has a Cognitive Complexity of 21 (exceeds 7 allowed). Consider refactoring.
      Open

          def encabezado(campo, options = {})
            campo = campo.to_s.sub(/_f\z/, '')
            campo = campo.to_s.sub(/_text\z/, '')
            clase = options[:clase] || @clase_modelo
            if options[:ordenable]
      Severity: Minor
      Found in pg_engine/app/helpers/pg_engine/index_helper.rb - 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

      File resource.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module PgEngine
        module Resource
          def self.included(clazz)
            # clazz.before_action :authenticate_user!
            clazz.helper_method :atributos_para_listar
      Severity: Minor
      Found in pg_engine/app/controllers/concerns/pg_engine/resource.rb - About 2 hrs to fix

        Method pg_respond_destroy has a Cognitive Complexity of 15 (exceeds 7 allowed). Consider refactoring.
        Confirmed

            def pg_respond_destroy(model, redirect_url = nil)
              if destroy_model(model)
                msg = "#{model.model_name.human} #{model.gender == 'f' ? 'borrada' : 'borrado'}"
                respond_to do |format|
                  if redirect_url.present?
        Severity: Minor
        Found in pg_engine/app/controllers/concerns/pg_engine/resource.rb - 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

        Method pg_respond_create has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
        Confirmed

            def pg_respond_create
              object = instancia_modelo
              respond_to do |format|
                if (@saved = object.save)
                  if params[:asociable]
        Severity: Minor
        Found in pg_engine/app/controllers/concerns/pg_engine/resource.rb - 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 flashMessage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function flashMessage (message, flashType = 'warning', toast = false) {
          const el = document.createElement('div')
          const toastClasses = toast ? 'position-absolute pg-toast' : ''
          let iconClasses
          let alertClassSuffix
        Severity: Minor
        Found in pg_layout/app/javascript/utils/utils.ts - About 1 hr to fix

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

            config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline',
                                                         item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
              b.use :html5
              b.optional :readonly
              b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
          Severity: Major
          Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
          pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 107..117

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 58.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline',
                                                           item_label_class: 'form-check-label', class: 'row mb-3' do |b|
              b.use :html5
              b.optional :readonly
              b.use :label, class: 'col-sm-3 col-form-label pt-0'
          Severity: Major
          Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
          pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 206..215

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 58.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label',
                                                  tag: 'fieldset', class: 'mb-3' do |b|
              b.use :html5
              b.optional :readonly
              b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
          Severity: Major
          Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
          pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 120..130

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 58.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label',
                                                    class: 'row mb-3' do |b|
              b.use :html5
              b.optional :readonly
              b.use :label, class: 'col-sm-3 col-form-label pt-0'
          Severity: Major
          Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
          pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 219..228

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 58.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method encabezado has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def encabezado(campo, options = {})
                campo = campo.to_s.sub(/_f\z/, '')
                campo = campo.to_s.sub(/_text\z/, '')
                clase = options[:clase] || @clase_modelo
                if options[:ordenable]
          Severity: Minor
          Found in pg_engine/app/helpers/pg_engine/index_helper.rb - 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

              Method pg_respond_create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Confirmed

                  def pg_respond_create
                    object = instancia_modelo
                    respond_to do |format|
                      if (@saved = object.save)
                        if params[:asociable]
              Severity: Minor
              Found in pg_engine/app/controllers/concerns/pg_engine/resource.rb - About 1 hr to fix

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

                    def pg_respond_destroy(model, redirect_url = nil)
                      if destroy_model(model)
                        msg = "#{model.model_name.human} #{model.gender == 'f' ? 'borrada' : 'borrado'}"
                        respond_to do |format|
                          if redirect_url.present?
                Severity: Minor
                Found in pg_engine/app/controllers/concerns/pg_engine/resource.rb - About 1 hr to fix

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

                      b.use :html5
                      b.use :placeholder
                      b.optional :maxlength
                      b.optional :minlength
                      b.optional :pattern
                  Severity: Major
                  Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
                  pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 290..302

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 52.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                      b.use :html5
                      b.use :placeholder
                      b.optional :maxlength
                      b.optional :minlength
                      b.optional :pattern
                  Severity: Major
                  Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
                  pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 50..61

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 52.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                      b.use :html5
                      b.optional :readonly
                      b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
                        bb.use :input, class: 'form-check-input', error_class: 'is-invalid'
                        bb.use :label, class: 'form-check-label'
                  Severity: Minor
                  Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 55 mins to fix
                  pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 96..103

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 46.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                      b.use :html5
                      b.optional :readonly
                      b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
                        bb.use :input, class: 'form-check-input', error_class: 'is-invalid'
                        bb.use :label, class: 'form-check-label'
                  Severity: Minor
                  Found in pg_engine/config/simple_form/simple_form_bootstrap.rb and 1 other location - About 55 mins to fix
                  pg_engine/config/simple_form/simple_form_bootstrap.rb on lines 306..313

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 46.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language