silegis-mg/editor-articulacao

View on GitHub

Showing 67 of 86 total issues

Function colarFragmento has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function colarFragmento(fragmento, editorCtrl, validacaoCtrl) {
    prepararDesfazer(fragmento, editorCtrl);

    let proximaSelecao = fragmento.lastChild;
    let selecao = editorCtrl.getSelection();
Severity: Minor
Found in src/ClipboardController.js - About 1 hr to fix

    Function normalizarParagrafo has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function normalizarParagrafo(paragrafo) {
        while (paragrafo.hasAttributes()) {
            paragrafo.removeAttribute(paragrafo.attributes[0].name);
        }
    
    
    Severity: Minor
    Found in src/lexml/exportarParaLexML.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 prepararDesfazer has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function prepararDesfazer(fragmento, editorCtrl) {
        var copia = [];
    
        for (let i = 0, l = fragmento.childNodes.length; i < l; i++) {
            copia.push(fragmento.childNodes[i]);
    Severity: Minor
    Found in src/ClipboardController.js - About 1 hr to fix

      Function polyfill has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

       function polyfill() {
          // IE 11 não tem Object.assing
      
          // Object polyfill from https://developer.mozilla.org/en-US/docs/Glossary/Polyfill
          if (!Object.assign) {
      Severity: Minor
      Found in src/hacks/polyfill.js - About 1 hr to fix

        Function constructor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor(elemento, opcoes) {
                var container, botoes, containerBotoes, ctrl;
        
                /* Se houver suporte ao shadow-dom, então vamos usá-lo
                 * para garantir o isolamento da árvore interna do componente
        Severity: Minor
        Found in src/ComponenteEdicao.js - About 1 hr to fix

          Function obterSelecao has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function obterSelecao(ctrl) {
              var selecao = ctrl.getSelection();
              var range = selecao && selecao.rangeCount > 0 ? selecao.getRangeAt(0) : null;
          
              if (range) {
          Severity: Minor
          Found in src/EditorArticulacaoController.js - About 1 hr to fix

            Function criarRotuloLexML has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function criarRotuloLexML(tipo, numero, unico, nEmenda, rotulos) {
                var elemento = document.createElementNS('http://www.lexml.gov.br/1.0', 'Rotulo');
            
                switch (tipo) {
                    case 'Artigo':
            Severity: Minor
            Found in src/lexml/exportarParaLexML.js - About 1 hr to fix

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

                  atualizarContexto() {
                      var elementoSelecionado = obterSelecao(this);
              
                      if (!elementoSelecionado) {
                          if (!this.contexto) {
              Severity: Minor
              Found in src/EditorArticulacaoController.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 prepararDesfazer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              function prepararDesfazer(fragmento, editorCtrl) {
                  var copia = [];
              
                  for (let i = 0, l = fragmento.childNodes.length; i < l; i++) {
                      copia.push(fragmento.childNodes[i]);
              Severity: Minor
              Found in src/ClipboardController.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 criarConteudoInline has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              function criarConteudoInline(origem, destino) {
                  var arvore = document.createTreeWalker(origem, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, null /* necesário no IE 11 */, null  /* necesário no IE 11 */);
                  var atual = {
                      /**
                       * Objeto de contexto de exportação anterior (este mesmo objeto)
              Severity: Minor
              Found in src/lexml/exportarParaLexML.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 criarConteudoInline has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function criarConteudoInline(origem, destino) {
                  var arvore = document.createTreeWalker(origem, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, null /* necesário no IE 11 */, null  /* necesário no IE 11 */);
                  var atual = {
                      /**
                       * Objeto de contexto de exportação anterior (este mesmo objeto)
              Severity: Minor
              Found in src/lexml/exportarParaLexML.js - About 1 hr to fix

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

                function transformarTextoPuro(texto, tipo) {
                    if (texto.length === 0) {
                        return;
                    }
                
                
                Severity: Minor
                Found in src/ClipboardController.js - About 1 hr to fix

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

                      constructor(elemento, opcoes) {
                          if (!(elemento instanceof Element)) {
                              throw 'Elemento não é um elemento do DOM.';
                          }
                  
                  
                  Severity: Minor
                  Found in src/EditorArticulacaoController.js - About 1 hr to fix

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

                    module.exports = function (config) {
                        config.set({
                            files: ['empacotamento/karma.js', 'test/karma/**/*.js'],
                            frameworks: ['jasmine'],
                            preprocessors: {
                    Severity: Minor
                    Found in karma.conf.js - About 1 hr to fix

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

                      function interpretarArticulacao(texto, formatoDestino, formatoOrigem) {
                          var json;
                      
                          try {
                              switch ((formatoOrigem || 'texto').toLowerCase()) {
                      Severity: Minor
                      Found in src/interpretadorArticulacao.js - About 1 hr to fix

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

                        function verificarPrimeiroDoTipo(dispositivo) {
                            var tipo = dispositivo.getAttribute('data-tipo');
                        
                            if (!tipo) {
                                return null;
                        Severity: Minor
                        Found in src/ContextoArticulacao.js - About 1 hr to fix

                          Function transformarEmEditor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function transformarEmEditor(elemento, editorCtrl, opcoes) {
                              let style = document.createElement('style');
                              style.innerHTML = css.toString().replace(/\${(.+?)}/g, (m, valor) => opcoes.rotulo[valor]);
                          
                              /* Se houver suporte ao shadow-dom, então vamos usá-lo
                          Severity: Minor
                          Found in src/EditorArticulacaoController.js - About 1 hr to fix

                            Function transformarEmLexML has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function transformarEmLexML(json) {
                                function reducaoInciso(prev, inciso, idx, array) {
                            
                                    var idInciso = array.prefixo + "_inc" + (idx + 1);
                            
                            
                            Severity: Minor
                            Found in src/interpretadorArticulacao.js - About 1 hr to fix

                              Function constructor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  constructor(elemento, opcoes) {
                                      if (!(elemento instanceof Element)) {
                                          throw 'Elemento não é um elemento do DOM.';
                                      }
                              
                              
                              Severity: Minor
                              Found in src/EditorArticulacaoController.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 transformarEmEditor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function transformarEmEditor(elemento, editorCtrl, opcoes) {
                                  let style = document.createElement('style');
                                  style.innerHTML = css.toString().replace(/\${(.+?)}/g, (m, valor) => opcoes.rotulo[valor]);
                              
                                  /* Se houver suporte ao shadow-dom, então vamos usá-lo
                              Severity: Minor
                              Found in src/EditorArticulacaoController.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

                              Severity
                              Category
                              Status
                              Source
                              Language