pasosdeJesus/sivel2_gen

View on GitHub
app/javascript/controllers/mapaosm_controller.js

Summary

Maintainability
F
4 days
Test Coverage

File mapaosm_controller.js has 423 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Controller } from "@hotwired/stimulus"

import Msip__Motor from "../msip/motor"


Severity: Minor
Found in app/javascript/controllers/mapaosm_controller.js - About 6 hrs to fix

    Function presentarMapaOsm has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      presentarMapaOsm(usuario_autenticado) {
        var usuario_aut_global = usuario_autenticado;
        // Borrar clase container y ocultar pie de página
        document.querySelector('.navbar').classList.add('navbarosm');
        document.querySelector('.card-body').classList.add('cardbodyosm');
    Severity: Major
    Found in app/javascript/controllers/mapaosm_controller.js - About 3 hrs to fix

      Function creaMarcador has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        creaMarcador(punto, codigo, titulo) {
          // Exportar los casos a formato GeoJson
          var marcadorCaso = new L.Marker(punto);
          // Acción al hacer clic en caso en el mapa
          marcadorCaso.on('click', clicMarcadorCaso);
      Severity: Major
      Found in app/javascript/controllers/mapaosm_controller.js - About 2 hrs to fix

        Function connect has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          connect() {
            console.log("Conexion de controlador Mapa osm");
            const usuarioAutenticado = this.data.get("usuarioAutenticado") === 'true';
            if (!this.constructor.marcadores) {
              this.constructor.marcadores = L.markerClusterGroup();
        Severity: Minor
        Found in app/javascript/controllers/mapaosm_controller.js - About 1 hr to fix

          Function clicMarcadorCaso has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function clicMarcadorCaso() {
                self.mostrarCargador();
                msip_arregla_puntomontaje(window);
                var ruta = window.puntomontaje + 'casos/';
                var urlSolicitud = ruta + codigo + ".json";  
          Severity: Minor
          Found in app/javascript/controllers/mapaosm_controller.js - About 1 hr to fix

            Function armarRutaConsulta has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              armarRutaConsulta(rutaSinPuntomontaje, usuarioAutenticado) {
                var ruta = window.puntomontaje + rutaSinPuntomontaje;
                var desde = document.getElementById('campo-desde').value;
                var hasta = document.getElementById('campo-hasta').value;
                var departamento = document.getElementById('departamento').value;
            Severity: Minor
            Found in app/javascript/controllers/mapaosm_controller.js - About 1 hr to fix

              Function agregarCasosOsm has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                agregarCasosOsm(usuario_autenticado) {
                  if (typeof window.formato_fecha === 'undefined') {
                    msip_prepara_eventos_comunes(window);
                  }
                  var urlSolicitud = this.armarRutaConsulta('casos.json', usuario_autenticado);
              Severity: Minor
              Found in app/javascript/controllers/mapaosm_controller.js - About 1 hr to fix

                Function obtener_info_victimas has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  obtener_info_victimas(victimas, prresp, caso) {
                    var victimasCont = '<div><table>' +
                      '<tr><td>Víctimas:</td><td>';
                    for (var cv in victimas) {
                      if (victimas.hasOwnProperty(cv)) {
                Severity: Minor
                Found in app/javascript/controllers/mapaosm_controller.js - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function capaInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  capaInfo(des, hec, vic) {
                    if (this.constructor.info != undefined) { // si ya tenía información se quita primero
                      this.constructor.info.remove(this.constructor.mapa); 
                    }
                    this.constructor.info.onAdd = function (mapa) {
                Severity: Minor
                Found in app/javascript/controllers/mapaosm_controller.js - About 1 hr to fix

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

                    armarRutaConsulta(rutaSinPuntomontaje, usuarioAutenticado) {
                      var ruta = window.puntomontaje + rutaSinPuntomontaje;
                      var desde = document.getElementById('campo-desde').value;
                      var hasta = document.getElementById('campo-hasta').value;
                      var departamento = document.getElementById('departamento').value;
                  Severity: Minor
                  Found in app/javascript/controllers/mapaosm_controller.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

                  Function presentarMapaOsm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    presentarMapaOsm(usuario_autenticado) {
                      var usuario_aut_global = usuario_autenticado;
                      // Borrar clase container y ocultar pie de página
                      document.querySelector('.navbar').classList.add('navbarosm');
                      document.querySelector('.card-body').classList.add('cardbodyosm');
                  Severity: Minor
                  Found in app/javascript/controllers/mapaosm_controller.js - About 35 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

                  Function connect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    connect() {
                      console.log("Conexion de controlador Mapa osm");
                      const usuarioAutenticado = this.data.get("usuarioAutenticado") === 'true';
                      if (!this.constructor.marcadores) {
                        this.constructor.marcadores = L.markerClusterGroup();
                  Severity: Minor
                  Found in app/javascript/controllers/mapaosm_controller.js - About 25 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

                  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

                  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

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

                      for (var cv in victimas) {
                        if (victimas.hasOwnProperty(cv)) {
                          var victima = victimas[cv];
                          victimasCont += ((typeof victima != 'undefined') && victima != "") ? victima + '<br />' : 'SIN INFORMACIÓN';
                        }
                  Severity: Major
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 1 hr to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 355..360

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

                  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

                      for (var cp in prresp) {
                        if (prresp.hasOwnProperty(cp)) {
                          var prrespel = prresp[cp];
                          victimasCont += ((typeof prrespel != 'undefined') && prrespel != "") ? prrespel + '<br />' : 'SIN INFORMACIÓN';
                        }
                  Severity: Major
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 1 hr to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 347..352

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

                  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

                    cierraCapaDiv(){
                      if (this.constructor.agregaCapaDiv != undefined) {
                        this.constructor.agregaCapaDiv.remove(this.constructor.mapa);
                      }
                    };
                  Severity: Minor
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 45 mins to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 400..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 50.

                  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

                    cerrarinfo(){
                      if (this.constructor.info != undefined) {
                        this.constructor.info.remove(this.constructor.mapa);
                      }
                    }
                  Severity: Minor
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 45 mins to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 476..480

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

                  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 (this.constructor.agregaCapaDiv != undefined) { // si había información se elimina
                        this.constructor.agregaCapaDiv.remove(this.constructor.mapa);
                      }
                  Severity: Minor
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 40 mins to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 369..371

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

                  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 (this.constructor.info != undefined) { // si ya tenía información se quita primero
                        this.constructor.info.remove(this.constructor.mapa); 
                      }
                  Severity: Minor
                  Found in app/javascript/controllers/mapaosm_controller.js and 1 other location - About 40 mins to fix
                  app/javascript/controllers/mapaosm_controller.js on lines 451..453

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status