pasosdeJesus/sivel2_gen

View on GitHub

Showing 410 of 410 total issues

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

      if (elem.multiple) {
        let opciones = elem.options
        let valores_multi= []
        for (const opc of opciones) {
          if(opc.selected) {
Severity: Major
Found in app/javascript/controllers/motor.js and 1 other location - About 3 hrs to fix
app/javascript/controllers/motor.js on lines 295..307

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

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

Function actualizarEdad has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  actualizarEdad(event){
    let anio = parseInt(this.anionacTarget.value);
    let mes = parseInt(this.mesnacTarget.value) - 1;
    let dia = parseInt(this.dianacTarget.value);

Severity: Major
Found in app/javascript/controllers/edad_controller.js - About 3 hrs to fix

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

              def presenta_mas_index(formato)
                formato.csv {
                  authorize! :exportaCSV, Sivel2Gen::Caso
                  atributos = %w{caso_id fecha ubicaciones victimas presponsables tipificacion memo}
                  r = CSV.generate(headers: true) do |csv|
    Severity: Major
    Found in lib/sivel2_gen/concerns/controllers/casos_controller.rb - About 3 hrs to fix

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

                def presenta_index
                  # Presentación
                  respond_to do |format|
                    if current_usuario || (Rails.configuration.x.sivel2_consweb_max &&
                        @conscaso.count <= Rails.configuration.x.sivel2_consweb_max.to_i)
      Severity: Major
      Found in lib/sivel2_gen/concerns/controllers/casos_controller.rb - About 3 hrs to fix

        Method personas_arma_filtros_sivel2_gen has 78 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def personas_arma_filtros_sivel2_gen
                    caniosnac = Msip::Persona.where('anionac IS NOT NULL').
                      pluck('distinct anionac').sort
        
                    cmesescasos = Sivel2Gen::Caso.all.pluck('distinct fecha').
        Severity: Major
        Found in lib/sivel2_gen/concerns/controllers/conteos_controller.rb - About 3 hrs to fix

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

                if l5>10000
                  l2 = ((l2/1000)+1)*1000
                  l3 = ((l3/1000)+1)*1000
                  l4 = ((l4/1000)+1)*1000
                  l5 = ((l5/1000)+1)*1000
          Severity: Major
          Found in app/helpers/sivel2_gen/vista_helper.rb and 1 other location - About 3 hrs to fix
          app/helpers/sivel2_gen/vista_helper.rb on lines 406..421

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

          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 l5>10000
                  l2 = ((l2/1000)+1)*1000
                  l3 = ((l3/1000)+1)*1000
                  l4 = ((l4/1000)+1)*1000
                  l5 = ((l5/1000)+1)*1000
          Severity: Major
          Found in app/helpers/sivel2_gen/vista_helper.rb and 1 other location - About 3 hrs to fix
          app/helpers/sivel2_gen/vista_helper.rb on lines 149..164

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

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

                    def personas_procesa_filtros_sivel2_gen(que1, tablas1, where1, que3, 
                                                            tablas3, where3)
                      @filtrosegun.each do |e, r|
                        if (params[:filtro] && params[:filtro][r[:nomfiltro]] && 
                            params[:filtro][r[:nomfiltro]] != '') 
          Severity: Minor
          Found in lib/sivel2_gen/concerns/controllers/conteos_controller.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 ubicacion_caso has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

                    def ubicacion_caso
                      r = ''
                      if self.caso && self.caso.ubicacionprincipal
                        if self.caso.ubicacionprincipal.pais_id == 170
                          r += self.caso.ubicacionprincipal.departamento ?
          Severity: Minor
          Found in lib/sivel2_gen/concerns/models/victima.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 create_sivel2_gen has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def create_sivel2_gen
                      @merr = ""
                      params2 = {}
                      if (!params[:caso] && !params2['caso'])
                        @merr = 'Faltan parámetros de caso'
          Severity: Major
          Found in lib/sivel2_gen/concerns/controllers/actos_controller.rb - About 2 hrs to fix

            Method categoria_presponsable has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                      def categoria_presponsable
                        consl= "WITH RECURSIVE cteRecursion AS (
                           SELECT id, 1 AS Level
                               FROM public.sivel2_gen_presponsable
                               WHERE id = 39
            Severity: Minor
            Found in lib/sivel2_gen/concerns/models/caso.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 asegura_camposdinamicos has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                      def self.asegura_camposdinamicos(caso, current_usuario_id, pestanas)
                        if caso.nil?  || caso.id.nil?
                          return
                        end
            
            
            Severity: Minor
            Found in lib/sivel2_gen/concerns/controllers/casos_controller.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 importa has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                      def importa
                        authorize! :create, Sivel2Gen::Caso
                        arc = params[:arc]
                        doc = nil
                        begin
            Severity: Minor
            Found in lib/sivel2_gen/concerns/controllers/casos_controller.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 personas has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                      def personas
                        authorize! :contar, Sivel2Gen::Caso
            
                        @pSegun = escapar_param(params, [:filtro, 'segun'])
                        @pMunicipio = escapar_param(params, [:filtro, 'municipio'])
            Severity: Major
            Found in lib/sivel2_gen/concerns/controllers/conteos_controller.rb - About 2 hrs to fix

              Method victimizaciones has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        def victimizaciones
                          authorize! :contar, Sivel2Gen::Caso
              
                          # Filtros
                          pFini = escapar_param(params, [:filtro, 'fechaini'])
              Severity: Major
              Found in lib/sivel2_gen/concerns/controllers/mapamun_controller.rb - About 2 hrs to fix

                Function crearCopiaDeVictima has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static crearCopiaDeVictima(obj, fobj) {
                    let div_victima = obj.parentElement.parentElement;
                    let valores_input= []
                    let valores_select= []
                    div_victima.querySelectorAll('input').forEach(elem => {
                Severity: Major
                Found in app/javascript/controllers/motor.js - About 2 hrs to fix

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

                              if(elem.multiple){
                                for(const val of valores_select[indice_tipo_select]){
                                  for (const opc of elem.options) {
                                    if(opc.value == val){
                                      opc.selected = true;
                  Severity: Major
                  Found in app/javascript/controllers/motor.js and 1 other location - About 2 hrs to fix
                  app/javascript/controllers/motor.js on lines 393..404

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

                  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(elem.multiple){
                              for(const val of valores_select[i]){
                                for (const opc of elem.options) {
                                  if(opc.value == val){
                                    opc.selected = true;
                  Severity: Major
                  Found in app/javascript/controllers/motor.js and 1 other location - About 2 hrs to fix
                  app/javascript/controllers/motor.js on lines 333..344

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

                  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

                        this.constructor.mapa.addLayer(this.constructor.baldosasOsm)
                          .addControl(filtro)
                          .addControl(L.control.zoom({
                            position:
                            'topleft'
                  Severity: Major
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 2 hrs to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 161..168

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

                  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

                        this.constructor.mapa.addLayer(this.constructor.baldosasOsm)
                          .addControl(filtro)
                          .addControl(L.control.zoom({
                            position:
                            'topleft'
                  Severity: Major
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 2 hrs to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 147..155

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

                  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