pasosdeJesus/msip

View on GitHub

Showing 272 of 272 total issues

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

            if !departamento_id ||
                Msip::Departamento.where(
                  id: departamento_id.to_i,
                  pais_id: opais.id,
                ).count == 0
Severity: Minor
Found in lib/msip/concerns/models/ubicacionpre.rb and 1 other location - About 50 mins to fix
lib/msip/concerns/models/ubicacionpre.rb on lines 272..282

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

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

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

              if ubi.count > 0
                # modificando existente
                ubi[0].tsitio_id = tsitio_id
                ubi[0].latitud = latitud
                ubi[0].longitud = longitud
Severity: Minor
Found in lib/msip/concerns/models/ubicacionpre.rb and 1 other location - About 50 mins to fix
lib/msip/concerns/models/ubicacionpre.rb on lines 394..403

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

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

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

              if ubi.count > 0
                # modificando existente
                ubi[0].tsitio_id = tsitio_id
                ubi[0].latitud = latitud
                ubi[0].longitud = longitud
Severity: Minor
Found in lib/msip/concerns/models/ubicacionpre.rb and 1 other location - About 50 mins to fix
lib/msip/concerns/models/ubicacionpre.rb on lines 413..422

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

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 new_modelo_path(o)
      n = "new_#{nombreobj(o)}_path"
      arr = ruta_responde_1p(n, o)
      if arr != []
        return arr[1]
Severity: Minor
Found in app/helpers/msip/modelo_helper.rb and 1 other location - About 50 mins to fix
app/helpers/msip/modelo_helper.rb on lines 201..214

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

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 edit_modelo_path(o)
      n = "edit_#{nombreobj(o)}_path"
      arr = ruta_responde_1p(n, o)
      if arr != []
        return arr[1]
Severity: Minor
Found in app/helpers/msip/modelo_helper.rb and 1 other location - About 50 mins to fix
app/helpers/msip/modelo_helper.rb on lines 184..197

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

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

Avoid deeply nested control flow statements.
Open

          if send(atr.to_s).to_s.include?("ActiveRecord_Associations_CollectionProxy")
            e = send(atr.to_s)
            e.inject("") do |memo, i|
              (memo == "" ? "" : memo + "; ") +
                (i.respond_to?("presenta_nombre") ? i.presenta_nombre.to_s : i.to_s)
Severity: Major
Found in app/models/msip/modelo.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if(typeof el.tomselect === 'undefined' &&
                      (el.tagName == "INPUT" || el.tagName == "SELECT")) {
                        new TomSelect(el, window.configuracionTomSelect);
                    }
    Severity: Major
    Found in app/javascript/controllers/motor.js - About 45 mins to fix

      Method coleccion_basica has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.coleccion_basica(basica, ultimos_ids = nil)
            h = basica.habilitados
            unless ultimos_ids.nil?
              idsh = h.map(&:id)
              lu = ultimos_ids
      Severity: Minor
      Found in app/helpers/msip/modelo_helper.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

      Method edad_de_fechanac_fecha has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def edad_de_fechanac_fecha(anionac, mesnac, dianac,
            anio, mes, dia)
      Severity: Minor
      Found in app/helpers/msip/edad_sexo_helper.rb - About 45 mins to fix

        Method item_nav_pestaña_bs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def item_nav_pestaña_bs(idit, titulo, elegida = false,
              clase_boton = "", &bloque)
              content_tag(
                :li,
                class: "nav-item",
        Severity: Minor
        Found in app/helpers/msip/bootstrap_helper.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

        Method formato_ubicacion_partes has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def formato_ubicacion_partes(pais_id, departamento_id, municipio_id,
              centropoblado_id, con_centropoblado, con_pais)
        Severity: Minor
        Found in app/helpers/msip/ubicacion_helper.rb - About 45 mins to fix

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

          function msip_ubicacionpre_expandible_busca_lugar(s, ubi) {
            root = window
            msip_arregla_puntomontaje(root)
            cnom = s.attr('id')
            v = $("#" + cnom).data('autocompleta')
          Severity: Minor
          Found in app/assets/javascripts/msip/ubicacionpre.js - 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

                    elsif respond_to?(atr)
                      r = send(atr)
                      if r
                        r.presenta_nombre
                      else
          Severity: Major
          Found in app/models/msip/modelo.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if n[p[i]]
                        n = n[p[i]]
                      else
                        return ""
                      end
            Severity: Major
            Found in app/helpers/msip/sql_helper.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if r.respond_to?(:presenta_nombre)
                            r.presenta_nombre
                          else
                            r.id.to_s
                          end
              Severity: Major
              Found in app/models/msip/modelo.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        elsif atr == "fechacreacion"
                          created_at
                        elsif atr == "fechacreacion_localizada"
                          Msip::FormatoFechaHelper.fecha_estandar_local(created_at)
                        elsif atr == "fechaactualizacion"
                Severity: Major
                Found in app/models/msip/modelo.rb - About 45 mins to fix

                  Method formato_ubicacion_partes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def formato_ubicacion_partes(pais_id, departamento_id, municipio_id,
                        centropoblado_id, con_centropoblado, con_pais)
                        r = ""
                        if pais_id.nil? || Msip::Pais.where(id: pais_id).count != 1
                          return r
                  Severity: Minor
                  Found in app/helpers/msip/ubicacion_helper.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

                                if(alertaerror && xhr.status !== 0 && xhr.responseText !== ''){
                                  alert('Error: el servicio respondió: ' + xhr.status + xhr.responseText);
                                }
                  Severity: Major
                  Found in app/javascript/controllers/motor.js - About 45 mins to fix

                    Method rehabilita_centropoblado has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def rehabilita_centropoblado(
                          id, municipio_id, cplocal_cod, nombre, observacion, fechacreacion
                        )
                    
                          # byebug
                    Severity: Minor
                    Found in app/helpers/msip/sql_helper.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

                    Method verificarutas has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def verificarutas
                                em = ""
                                unless File.directory?(Msip.ruta_anexos)
                                  em += "No existe ruta de anexos '#{Msip.ruta_anexos}'. "
                                end
                    Severity: Minor
                    Found in lib/msip/concerns/controllers/hogar_controller.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

                    Severity
                    Category
                    Status
                    Source
                    Language