pasosdeJesus/msip

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

Summary

Maintainability
F
4 days
Test Coverage

Function ponerTema has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static ponerTema(root, tema) {
    console.log("entro a msip_ pone_tema")
    document.querySelectorAll('.table-striped>tbody>tr:nth-child(odd)').forEach((element) => {
      element.style.backgroundColor = tema.fondo_lista;
    });
Severity: Major
Found in app/javascript/controllers/motor.js - About 2 hrs to fix

    Function enviarAutomaticoFormulario has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      static enviarAutomaticoFormulario(f, metodo = 'GET', tipo = 'script', alertaerror = true, vcommit = 'Enviar', agenviarautom = true) {
        const root = window;
        const t = Date.now();
        let d = -1;
        if (root.msip_enviarautomatico_t) {
    Severity: Minor
    Found in app/javascript/controllers/motor.js - 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

    File motor.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    export default class Msip__Motor {
      /* 
       * Librería de funciones comunes.
       * Aunque no es un controlador lo dejamos dentro del directorio
    Severity: Minor
    Found in app/javascript/controllers/motor.js - About 2 hrs to fix

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

        static enviarAutomaticoFormulario(f, metodo = 'GET', tipo = 'script', alertaerror = true, vcommit = 'Enviar', agenviarautom = true) {
          const root = window;
          const t = Date.now();
          let d = -1;
          if (root.msip_enviarautomatico_t) {
      Severity: Minor
      Found in app/javascript/controllers/motor.js - About 1 hr to fix

        Function remplazarOpcionesSelect has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static remplazarOpcionesSelect(
            idElemento, nuevasop, usatomselect = false, cid = 'id',
            cetiqueta = 'nombre', opvacia = false
          ) {
            let elemento = document.getElementById(idElemento)
        Severity: Minor
        Found in app/javascript/controllers/motor.js - About 1 hr to fix

          Function remplazarOpcionesSelect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            static remplazarOpcionesSelect(
              idElemento, nuevasop, usatomselect = false, cid = 'id',
              cetiqueta = 'nombre', opvacia = false
            ) {
              let elemento = document.getElementById(idElemento)
          Severity: Minor
          Found in app/javascript/controllers/motor.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 partirFechaLocalizada has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            static partirFechaLocalizada(fechaLocalizada, formato) {
              let anio = 1900
              let dia = 15
              let mes = 6
              if (formato == 'dd/M/yyyy' || formato == 'dd-M-yyyy') {
          Severity: Minor
          Found in app/javascript/controllers/motor.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 ponerTemaUsuarioAjax has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static async ponerTemaUsuarioAjax(){
              var root = window
              var ruta = 'temausuario'
              var datos = {}
              var t = Date.now();
          Severity: Minor
          Found in app/javascript/controllers/motor.js - About 1 hr 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

              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

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

                  static async ponerTemaUsuarioAjax(){
                    var root = window
                    var ruta = 'temausuario'
                    var datos = {}
                    var t = Date.now();
                Severity: Minor
                Found in app/javascript/controllers/motor.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

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

                    document.querySelectorAll('.btn-primary').forEach((element) => {
                      element.style.backgroundImage = `linear-gradient(to bottom, ${tema.btn_primario_fondo_ini}, ${tema.btn_primario_fondo_fin})`;
                      element.style.color = tema.btn_primario_fuente;
                    });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 2 other locations - About 2 hrs to fix
                app/javascript/controllers/motor.js on lines 101..104
                app/javascript/controllers/motor.js on lines 109..112

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

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

                    document.querySelectorAll('.btn').forEach((element) => {
                      element.style.backgroundImage = `linear-gradient(to bottom, ${tema.btn_accion_fondo_ini}, ${tema.btn_accion_fondo_fin})`;
                      element.style.color = tema.btn_accion_fuente;
                    });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 2 other locations - About 2 hrs to fix
                app/javascript/controllers/motor.js on lines 105..108
                app/javascript/controllers/motor.js on lines 109..112

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

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

                    document.querySelectorAll('.btn-danger').forEach((element) => {
                      element.style.backgroundImage = `linear-gradient(to bottom, ${tema.btn_peligro_fondo_ini}, ${tema.btn_peligro_fondo_fin})`;
                      element.style.color = tema.btn_peligro_fuente;
                    });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 2 other locations - About 2 hrs to fix
                app/javascript/controllers/motor.js on lines 101..104
                app/javascript/controllers/motor.js on lines 105..108

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

                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 (typeof el.tomselect == 'undefined' && 
                      (el.tagName == "INPUT" || el.tagName == "SELECT") &&
                      window.TomSelect) {
                      new window.TomSelect(el, window.configuracionTomSelect)
                    }
                Severity: Major
                Found in app/javascript/controllers/motor.js and 1 other location - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 164..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 65.

                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 (typeof el.tomselect == 'undefined' &&
                      (el.tagName == "INPUT" || el.tagName == "SELECT") &&
                      window.TomSelect) {
                      new window.TomSelect(el, window.configuracionTomSelect)
                    }
                Severity: Major
                Found in app/javascript/controllers/motor.js and 1 other location - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 43..47

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

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

                    document.querySelectorAll('.alert-success').forEach((element) => {
                      element.style.color = tema.alerta_exito_fuente;
                      element.style.backgroundColor = tema.alerta_exito_fondo;
                    });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 2 other locations - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 97..100
                app/javascript/controllers/motor.js on lines 117..120

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 63.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                    document.querySelectorAll('.alert-danger').forEach((element) => {
                      element.style.color = tema.alerta_problema_fuente;
                      element.style.backgroundColor = tema.alerta_problema_fondo;
                    });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 2 other locations - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 93..96
                app/javascript/controllers/motor.js on lines 117..120

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 63.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                    document.querySelectorAll('.msip-sf-bs-input:not(.form-check-input)').forEach((element) => {
                      element.style.backgroundColor = tema.fondo;
                      element.style.color = tema.color_fuente;
                    });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 2 other locations - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 93..96
                app/javascript/controllers/motor.js on lines 97..100

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 63.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                      if (typeof elemento.tomselect != 'undefined') {
                        elemento.tomselect.clear() 
                        elemento.tomselect.clearOptions()
                        elemento.tomselect.sync()
                        elemento.tomselect.refreshOptions()
                Severity: Major
                Found in app/javascript/controllers/motor.js and 1 other location - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 169..174

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

                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 (el.tomselect) {
                      el.tomselect.clear()
                      el.tomselect.clearOptions()
                      el.tomselect.sync()
                      el.tomselect.refreshOptions()
                Severity: Major
                Found in app/javascript/controllers/motor.js and 1 other location - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 331..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 60.

                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

                      element.addEventListener('mouseover', () => {
                        element.style.color = tema.color_flota_subitem_fuente;
                        element.style.backgroundColor = tema.color_flota_subitem_fondo;
                      });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 1 other location - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 88..91

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

                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

                      element.addEventListener('mouseout', () => {
                        element.style.color = tema.nav_fuente;
                        element.style.backgroundColor = tema.nav_fin;
                      });
                Severity: Major
                Found in app/javascript/controllers/motor.js and 1 other location - About 1 hr to fix
                app/javascript/controllers/motor.js on lines 83..86

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

                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