pasosdeJesus/mr519_gen

View on GitHub

Showing 30 of 30 total issues

Method presenta_valor has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

          def presenta_valor(con_nombre_campo = true)
            r = ""
            r = "#{campo.presenta_nombre}: " if con_nombre_campo
            if !campo.tipo ||
                campo.tipo == Mr519Gen::ApplicationHelper::TEXTO ||
Severity: Minor
Found in lib/mr519_gen/concerns/models/valorcampo.rb - 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

Method presenta_gen_mr519 has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def presenta_gen_mr519(atr)
        if atr.to_s.include?(".")
          pa = atr.split(".")
          f = Mr519Gen::Formulario
            .where(nombreinterno: pa[0])
Severity: Minor
Found in app/models/mr519_gen/modelo.rb - 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

Method analiza_respuestas has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def analiza_respuestas(respuestafor_ids, titulo, consolidado, _menserr)
      resps = Mr519Gen::Respuestafor.where(id: respuestafor_ids)
      if resps.count == 0
        menserr = "No hay encuestas respondidas"
        return false
Severity: Major
Found in app/helpers/mr519_gen/application_helper.rb - About 3 hrs to fix

    Function mr519ef_prepara has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function mr519ef_prepara() {
    
      var opciones = {
        float: true,
        auto: false,
    Severity: Major
    Found in app/assets/javascripts/mr519_gen/edita_formulario.js - About 2 hrs to fix

      Method analiza_respuestas has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def analiza_respuestas(respuestafor_ids, titulo, consolidado, _menserr)
            resps = Mr519Gen::Respuestafor.where(id: respuestafor_ids)
            if resps.count == 0
              menserr = "No hay encuestas respondidas"
              return false
      Severity: Minor
      Found in app/helpers/mr519_gen/application_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

      Method presenta_valor has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def presenta_valor(con_nombre_campo = true)
                  r = ""
                  r = "#{campo.presenta_nombre}: " if con_nombre_campo
                  if !campo.tipo ||
                      campo.tipo == Mr519Gen::ApplicationHelper::TEXTO ||
      Severity: Major
      Found in lib/mr519_gen/concerns/models/valorcampo.rb - About 2 hrs to fix

        Method copia has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

                  def copia
                    if !params || !params[:formulario_id]
                      render(inline: "Falta parámetro formulario_id")
                      return
                    end
        Severity: Minor
        Found in lib/mr519_gen/concerns/controllers/formularios_controller.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 resultados has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def resultados
                    authorize!(:manage, Mr519Gen::Encuestapersona)
                    if !params || !params[:formulario_id]
                      render(inline: "Falta parámetro formulario_id")
                      return
        Severity: Minor
        Found in lib/mr519_gen/concerns/controllers/encuestaspersona_controller.rb - About 1 hr to fix

          Method creartodousuario has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def creartodousuario
                      if !params || !params[:encuestausuario_id]
                        render(inline: "Falta parámetro encuestausuario_id")
                        return
                      end
          Severity: Minor
          Found in lib/mr519_gen/concerns/controllers/encuestasusuario_controller.rb - About 1 hr to fix

            Method presenta_gen_mr519 has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def presenta_gen_mr519(atr)
                    if atr.to_s.include?(".")
                      pa = atr.split(".")
                      f = Mr519Gen::Formulario
                        .where(nombreinterno: pa[0])
            Severity: Minor
            Found in app/models/mr519_gen/modelo.rb - About 1 hr to fix

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

                $(document).on('cocoon:after-remove', '#campos', function(e, campo){
                  if (e.target.id == "campos") { 
                    document.grid.removeAll()
                    mr519ef_texto_a_visual()
                  }  
              Severity: Major
              Found in app/assets/javascripts/mr519_gen/edita_formulario.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/mr519_gen/edita_formulario.js on lines 132..137

              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 63.

              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

                $(document).on('change', '#campos',function(event, items) {
                  if (event.target.id == "campos") { 
                    document.grid.removeAll()
                  mr519ef_texto_a_visual()
                  }
              Severity: Major
              Found in app/assets/javascripts/mr519_gen/edita_formulario.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/mr519_gen/edita_formulario.js on lines 125..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 63.

              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 copia has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        def copia
                          if !params || !params[:formulario_id]
                            render(inline: "Falta parámetro formulario_id")
                            return
                          end
              Severity: Minor
              Found in lib/mr519_gen/concerns/controllers/formularios_controller.rb - About 1 hr to fix

                Function mr519ef_texto_a_visual has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function mr519ef_texto_a_visual() {
                  document.querySelectorAll('[id^=formulario_campo_attributes_][id$=_id]').forEach((i) => {
                    console.log(i)
                    if (i.parentElement.parentElement.parentElement.getAttribute('style') === null  || !i.parentElement.parentElement.parentElement.getAttribute('style').includes('display: none')) {
                      // No agrega a esquema visual los eliminados
                Severity: Minor
                Found in app/assets/javascripts/mr519_gen/edita_formulario.js - About 1 hr to fix

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

                            def update
                              params[:encuestapersona][:fechacambio_localizada] =
                                Msip::FormatoFechaHelper.fecha_estandar_local(Date.today)
                              @encuestapersona = @registro =
                                Mr519Gen::Encuestapersona.find(params[:id])
                  Severity: Minor
                  Found in lib/mr519_gen/concerns/controllers/encuestaspersona_controller.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

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

                            def lista_params_mr519_gen
                              l = atributos_form
                              l[l.index(:persona)] = :persona_id if l.index(:persona)
                              l[l.index(:formulariodec)] = :formulario_id if l.index(:formulariodec)
                              l += [respuestafor_attributes: [
                  lib/mr519_gen/concerns/controllers/encuestasusuario_controller.rb on lines 187..202

                  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 44.

                  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

                            def lista_params
                              l = atributos_form
                              l[l.index(:usuario)] = :usuario_id if l.index(:usuario)
                              l[l.index(:formulario)] = :formulario_id if l.index(:formulario)
                              l += [respuestafor_attributes: [
                  lib/mr519_gen/concerns/controllers/encuestaspersona_controller.rb on lines 211..226

                  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 44.

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

                            def fechas_en_orden
                              if fechafin && fechainicio && fechafin < fechainicio
                                errors.add(:fechainicio, "La fecha de inicio debe ser " +
                                           " anterior a la de terminación")
                              end
                  Severity: Minor
                  Found in lib/mr519_gen/concerns/models/encuestausuario.rb - 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

                                r += op.take.nombre if op.count == 1
                  Severity: Major
                  Found in lib/mr519_gen/concerns/models/valorcampo.rb - About 45 mins to fix

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

                                cuenta = Mr519Gen::Valorcampo.where(campo_id: c.id)
                                  .where("respuestafor_id IN (#{resps.map(&:id).join(",")})")
                                  .where("valor = ?", rb.id.to_s).count
                                cons += sep + "#{rb.nombre}: #{cuenta}"
                                sep = "<br> ".html_safe
                    Severity: Minor
                    Found in app/helpers/mr519_gen/application_helper.rb and 1 other location - About 45 mins to fix
                    app/helpers/mr519_gen/application_helper.rb on lines 135..139

                    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 40.

                    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