pasosdeJesus/sivel2_gen

View on GitHub

Showing 410 of 410 total issues

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

              if v['organizacion_armada']
                if Sivel2Gen::Presponsable.where('TRIM(nombre)=?', v['organizacion_armada'].strip).count == 1
                  self.organizacionarmada = Sivel2Gen::Presponsable.where('TRIM(nombre)=?', v['organizacion_armada'].strip).ids[0]
                else
                  menserror << "En la tabla Presponsable no existe " +
Severity: Major
Found in lib/sivel2_gen/concerns/models/combatiente.rb and 8 other locations - About 1 hr to fix
lib/sivel2_gen/concerns/models/combatiente.rb on lines 65..76
lib/sivel2_gen/concerns/models/combatiente.rb on lines 80..91
lib/sivel2_gen/concerns/models/combatiente.rb on lines 96..107
lib/sivel2_gen/concerns/models/combatiente.rb on lines 126..137
lib/sivel2_gen/concerns/models/victima.rb on lines 401..412
lib/sivel2_gen/concerns/models/victima.rb on lines 416..427
lib/sivel2_gen/concerns/models/victima.rb on lines 431..442
lib/sivel2_gen/concerns/models/victima.rb on lines 446..457

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

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 9 locations. Consider refactoring.
Open

            if v['iglesia']
              if Sivel2Gen::Iglesia.where('TRIM(nombre)=?', v['iglesia'].strip).count == 1
                self.iglesia_id = Sivel2Gen::Iglesia.where('TRIM(nombre)=?', v['iglesia'].strip).ids[0]
              else
                menserror << "En la tabla básica Iglesia no existe " +
Severity: Major
Found in lib/sivel2_gen/concerns/models/victima.rb and 8 other locations - About 1 hr to fix
lib/sivel2_gen/concerns/models/combatiente.rb on lines 65..76
lib/sivel2_gen/concerns/models/combatiente.rb on lines 80..91
lib/sivel2_gen/concerns/models/combatiente.rb on lines 96..107
lib/sivel2_gen/concerns/models/combatiente.rb on lines 111..122
lib/sivel2_gen/concerns/models/combatiente.rb on lines 126..137
lib/sivel2_gen/concerns/models/victima.rb on lines 401..412
lib/sivel2_gen/concerns/models/victima.rb on lines 416..427
lib/sivel2_gen/concerns/models/victima.rb on lines 446..457

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

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 9 locations. Consider refactoring.
Open

            if v['ocupacion']
              if Sivel2Gen::Profesion.where('TRIM(nombre)=?', v['ocupacion'].strip).count == 1
                self.profesion_id = Sivel2Gen::Profesion.where('TRIM(nombre)=?', v['ocupacion'].strip).ids[0]
              else
                menserror << "En la tabla básica Profesion no existe " +
Severity: Major
Found in lib/sivel2_gen/concerns/models/victima.rb and 8 other locations - About 1 hr to fix
lib/sivel2_gen/concerns/models/combatiente.rb on lines 65..76
lib/sivel2_gen/concerns/models/combatiente.rb on lines 80..91
lib/sivel2_gen/concerns/models/combatiente.rb on lines 96..107
lib/sivel2_gen/concerns/models/combatiente.rb on lines 111..122
lib/sivel2_gen/concerns/models/combatiente.rb on lines 126..137
lib/sivel2_gen/concerns/models/victima.rb on lines 416..427
lib/sivel2_gen/concerns/models/victima.rb on lines 431..442
lib/sivel2_gen/concerns/models/victima.rb on lines 446..457

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

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 9 locations. Consider refactoring.
Open

              if v['organizacion']
                if Sivel2Gen::Organizacion.where('TRIM(nombre)=?', v['organizacion'].strip).count == 1
                  self.organizacion_id = Sivel2Gen::Organizacion.where('TRIM(nombre)=?', v['organizacion'].strip).ids[0]
                else
                  menserror << "En la tabla básica Organización no existe " +
Severity: Major
Found in lib/sivel2_gen/concerns/models/combatiente.rb and 8 other locations - About 1 hr to fix
lib/sivel2_gen/concerns/models/combatiente.rb on lines 65..76
lib/sivel2_gen/concerns/models/combatiente.rb on lines 96..107
lib/sivel2_gen/concerns/models/combatiente.rb on lines 111..122
lib/sivel2_gen/concerns/models/combatiente.rb on lines 126..137
lib/sivel2_gen/concerns/models/victima.rb on lines 401..412
lib/sivel2_gen/concerns/models/victima.rb on lines 416..427
lib/sivel2_gen/concerns/models/victima.rb on lines 431..442
lib/sivel2_gen/concerns/models/victima.rb on lines 446..457

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

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 9 locations. Consider refactoring.
Open

            if v['organizacion']
              if Sivel2Gen::Organizacion.where('TRIM(nombre)=?', v['organizacion'].strip).count == 1
                self.organizacion_id = Sivel2Gen::Organizacion.where('TRIM(nombre)=?', v['organizacion'].strip).ids[0]
              else
                menserror << "En la tabla básica Organización no existe " +
Severity: Major
Found in lib/sivel2_gen/concerns/models/victima.rb and 8 other locations - About 1 hr to fix
lib/sivel2_gen/concerns/models/combatiente.rb on lines 65..76
lib/sivel2_gen/concerns/models/combatiente.rb on lines 80..91
lib/sivel2_gen/concerns/models/combatiente.rb on lines 96..107
lib/sivel2_gen/concerns/models/combatiente.rb on lines 111..122
lib/sivel2_gen/concerns/models/combatiente.rb on lines 126..137
lib/sivel2_gen/concerns/models/victima.rb on lines 401..412
lib/sivel2_gen/concerns/models/victima.rb on lines 416..427
lib/sivel2_gen/concerns/models/victima.rb on lines 431..442

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

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 9 locations. Consider refactoring.
Open

              if v['resultado_agresion']
                if Sivel2Gen::Resagresion.where('TRIM(nombre)=?', v['resultado_agresion'].strip).count == 1
                  self.resagresion_id = Sivel2Gen::Resagresion.where('TRIM(nombre)=?', v['resultado_agresion'].strip).ids[0]
                else
                  menserror << "En la tabla resultado agresión no exste " +
Severity: Major
Found in lib/sivel2_gen/concerns/models/combatiente.rb and 8 other locations - About 1 hr to fix
lib/sivel2_gen/concerns/models/combatiente.rb on lines 65..76
lib/sivel2_gen/concerns/models/combatiente.rb on lines 80..91
lib/sivel2_gen/concerns/models/combatiente.rb on lines 96..107
lib/sivel2_gen/concerns/models/combatiente.rb on lines 111..122
lib/sivel2_gen/concerns/models/victima.rb on lines 401..412
lib/sivel2_gen/concerns/models/victima.rb on lines 416..427
lib/sivel2_gen/concerns/models/victima.rb on lines 431..442
lib/sivel2_gen/concerns/models/victima.rb on lines 446..457

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

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 filtros_victimizaciones_gen has 11 arguments (exceeds 4 allowed). Consider refactoring.
Open

            pFini, pFfin, pTviolencia, pEtiqueta1, pEtiqueta2, 
            pExcluirCateRep, pSegun, pDepartamento, pMunicipio, otro= nil,
            pCategoria = nil)
Severity: Major
Found in lib/sivel2_gen/concerns/controllers/conteos_controller.rb - About 1 hr to fix

    Function operarElegida has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static operarElegida (eorig, cadpersona, id, otrosop) {
        Msip__Motor.arreglarPuntomontaje()
        vic_position = eorig.target.id.split("_")[3]
        const cs = id.split(';')
        const idPersona = cs[0]
    Severity: Minor
    Found in app/javascript/controllers/AutocompletaAjaxVictimas.js - About 1 hr to fix

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

                def consulta_base_sivel2_gen
                  r = "SELECT caso.id as caso_id, caso.fecha, caso.memo, 
              ARRAY_TO_STRING(ARRAY(SELECT COALESCE(departamento.nombre, '') ||  
              ' / ' || COALESCE(municipio.nombre, '')
              FROM public.msip_ubicacion AS ubicacion 
      Severity: Minor
      Found in lib/sivel2_gen/concerns/models/conscaso.rb - About 1 hr to fix

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

                  def importa(datosent, datossal, menserror, opciones = {})
                    pais = Msip::Pais.
                      where('nombre ILIKE ?', datosent['pais']).ids[0]
                    self.pais_id = pais || Msip.paisomision 
                    dep = Msip::Departamento.
        Severity: Minor
        Found in lib/sivel2_gen/concerns/models/ubicacion.rb - About 1 hr to fix

          Function operarElegida has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static operarElegida (eorig, cadgrupo, idGrupo, otrosop) {
              Msip__Motor.arreglarPuntomontaje()
              vicol_posicion = eorig.target.id.split("_")[3]
              const divcp = eorig.target.closest('.' +
                  Sivel2Gen__AutocompletaAjaxColectivas.claseEnvoltura)
          Severity: Minor
          Found in app/javascript/controllers/AutocompletaAjaxColectivas.js - About 1 hr to fix

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

                        if datosent['acto']
                          if datosent['acto'].kind_of?(Array)
                            datosent['acto'].each do |ac|
                              actocol = Sivel2Gen::Actocolectivo.new
                              actocol.caso_id = self.id
            Severity: Major
            Found in lib/sivel2_gen/concerns/models/caso.rb and 1 other location - About 1 hr to fix
            lib/sivel2_gen/concerns/models/caso.rb on lines 421..433

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

            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

                        if datosent['acto']
                          if datosent['acto'].kind_of?(Array)
                            datosent['acto'].each do |ac|
                              acto = Sivel2Gen::Acto.new
                              acto.caso_id = self.id
            Severity: Major
            Found in lib/sivel2_gen/concerns/models/caso.rb and 1 other location - About 1 hr to fix
            lib/sivel2_gen/concerns/models/caso.rb on lines 437..449

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

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

                      def arma_estfiltrosm_gen
                        f = {
                          'CATEGORIAS' => {
                            nomfiltro: nil,
                            coleccion: nil,

              Method genconsulta_victimizaciones has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                          pFini, pFfin, pTviolencia, pEtiqueta1, pEtiqueta2, pExcluirCateRep,
                          pSegun, pDepartamento, pMunicipio, pCategoria = nil)
              Severity: Major
              Found in lib/sivel2_gen/concerns/controllers/conteos_controller.rb - About 1 hr to fix

                Method formato_ubicacion has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def formato_ubicacion u, con_centropoblado = true
                      r = "";
                      if u
                        r = Msip::Pais.find(u.pais_id).nombre
                        if u.departamento_id
                Severity: Minor
                Found in app/helpers/sivel2_gen/ubicacion_helper.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 edad_de_fechanac_fecha has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def edad_de_fechanac_fecha(anionac, mesnac, dianac, 
                                                  anio, mes, dia)
                      if anionac.nil? || anionac == ''
                        return -1
                      end
                Severity: Minor
                Found in app/helpers/sivel2_gen/rangoedad_helper.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 nueva has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                          def nueva
                            if params[:caso_id]
                              @casoetiqueta = Sivel2Gen::CasoEtiqueta.new
                              @casoetiqueta.caso_id = params[:caso_id]
                              @casoetiqueta.etiqueta_id = Msip::Etiqueta.count > 0 ? Msip::Etiqueta.take.id : 0
                Severity: Minor
                Found in lib/sivel2_gen/concerns/controllers/caso_etiquetas_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 genvic_tabla has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                          def genvic_tabla(titulo, filas, tittotales, where1)
                            cuerpo = []
                            tot = 0;
                            filas.each do |f|
                              s = 0;
                Severity: Minor
                Found in lib/sivel2_gen/concerns/controllers/conteos_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 calcula_de_depmun has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                          def calcula_de_depmun(departamento_id, municipio_id)
                            if departamento_id && 
                                Sivel2Gen::DepartamentoRegion.where(
                                  departamento_id: departamento_id).count > 0
                              dr = Sivel2Gen::DepartamentoRegion.
                Severity: Minor
                Found in lib/sivel2_gen/concerns/models/region.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

                Severity
                Category
                Status
                Source
                Language