silegis-mg/editor-articulacao

View on GitHub

Showing 67 of 86 total issues

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

function transformar(texto, tipo, continuacao) {
    var fragmento;

    if (continuacao) {
        fragmento = transformarTextoPuro(texto, 'continuacao');
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 alterarTipoDispositivoSelecionado has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    alterarTipoDispositivoSelecionado(novoTipo) {
        this.atualizarContexto();

        if (!this.contexto) {
            throw 'Não há contexto atual.';
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 _normalizarDispositivo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    _normalizarDispositivo(dispositivo, contexto) {
        while (dispositivo && !dispositivo.hasAttribute('data-tipo')) {
            dispositivo = dispositivo.parentElement;
        }

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

        possuiSubtipo(subtipo) {
            switch (this.tipo) {
                case 'Articulacao':
                    return subtipo === 'Artigo' || subtipo === 'Titulo' || subtipo === 'Capitulo' || subtipo === 'Secao' || subtipo === 'Livro' || subtipo === 'Parte';

Severity: Minor
Found in src/lexml/exportarParaLexML.js - About 1 hr to fix

    Function criarElementoLexML has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function criarElementoLexML(tipo, conteudo, idPai, idxFilho, unico, nEmenda, rotulos) {
        var elemento, id;
    
        id = tipo.substr(0, 3).toLowerCase();
        id = idPai ? idPai + '_' + id : id;
    Severity: Minor
    Found in src/lexml/exportarParaLexML.js - About 1 hr to fix

      Function hackInterceptarKeydown has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function hackInterceptarKeydown(keyboardEvent, editorCtrl) {
          /* Somente serão tratadas as alterações de conteúdo. Portanto,
           * se houver qualquer tecla modificativa (ctrl, alt ou meta),
           * o evento será ignorado. O evento só será tratado se a tecla for
           * de conteúdo (letra, número ou enter), ou remoção (delete, backspace).
      Severity: Minor
      Found in src/hacks/chrome.js - About 1 hr to fix

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

        function obterDispositivoAnterior(dispositivo, elementoArticulacao) {
            while (dispositivo && !dispositivo.hasAttribute('data-tipo') && dispositivo !== elementoArticulacao) {
                dispositivo = dispositivo.parentElement;
            }
        
        
        Severity: Minor
        Found in src/ContextoArticulacao.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 _normalizarParagrafo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _normalizarParagrafo(dispositivo) {
                let anterior = encontrarDispositivoAnteriorDoTipo(dispositivo, ['artigo', 'paragrafo']);
                let posterior = encontrarDispositivoPosteriorDoTipo(dispositivo, ['artigo', 'paragrafo']);
        
                if (dispositivo.getAttribute('data-tipo') === 'paragrafo' || dispositivo.getAttribute('data-tipo') === 'continuacao') {
        Severity: Minor
        Found in src/EditorArticulacaoController.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if (!keyboardEvent.ctrlKey && !keyboardEvent.altKey && !keyboardEvent.metaKey &&
                  keyboardEvent.key.length === 1 || keyboardEvent.key === 'Delete' || keyboardEvent.key === 'Backspace' ||
                  keyboardEvent.key === 'Enter') {
          
                  let selection = editorCtrl.getSelection();
          Severity: Major
          Found in src/hacks/chrome.js - About 1 hr to fix

            Function transformar has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                transformar(elementoEditor, ctrl, contexto, sequencia, event) {
                    if (contexto.cursor.dispositivo.textContent.trim().length === 0) {
                        let novoTipo = {
                            item: 'alinea',
                            alinea: 'inciso',

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

            function hackAlterarTipo(ctrl, metodo, argumentos) {
                let dispositivo = ctrl.contexto.cursor.dispositivo;
                let contadoresAntigos = extrairContadores(dispositivo);
                let retorno  = metodo.apply(ctrl, argumentos);
                let contadoresNovos = extrairContadores(dispositivo, contadoresAntigos.hash);
            Severity: Minor
            Found in src/hacks/chrome.js - About 55 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 criarElementoLexML has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function criarElementoLexML(tipo, conteudo, idPai, idxFilho, unico, nEmenda, rotulos) {
            Severity: Major
            Found in src/lexml/exportarParaLexML.js - About 50 mins to fix

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

              function substituirSet() {
                  function substituirMetodo(metodo) {
                      if (typeof SetNativo.prototype[metodo] === 'function') {
                          window.Set.prototype[metodo] = function() { return this.$set[metodo].apply(this.$set, arguments); };
                      }
              Severity: Minor
              Found in src/hacks/ie.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 interceptarApos has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function interceptarApos(objeto, metodo, interceptador) {
                  if (!objeto) throw 'Objeto não fornecido.';
                  if (!metodo) throw 'Método não fornecido.';
                  if (!interceptador) throw 'Interceptador não fornecido.';
              
              
              Severity: Minor
              Found in src/hacks/interceptador.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 interceptar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function interceptar(objeto, metodo, interceptador) {
                  if (!objeto) throw 'Objeto não fornecido.';
                  if (!metodo) throw 'Método não fornecido.';
                  if (!interceptador) throw 'Interceptador não fornecido.';
              
              
              Severity: Minor
              Found in src/hacks/interceptador.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

              Avoid deeply nested control flow statements.
              Open

                                      if (item instanceof tipo[j]) {
                                          return item;
                                      }
              Severity: Major
              Found in src/interpretadorArticulacao.js - About 45 mins to fix

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

                function aoColar(event, clipboardCtrl) {
                    var clipboardData = event.clipboardData || window.clipboardData;
                    var itens = clipboardData.items;
                
                    if (itens) {
                Severity: Minor
                Found in src/ClipboardController.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

                Avoid deeply nested control flow statements.
                Open

                                        if (regexp.reiniciar) {
                                            contexto.ultimoItem = null;
                                        }
                Severity: Major
                Found in src/interpretadorArticulacao.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  do {
                                      startContainer = startContainer.firstElementChild;
                                  } while (startContainer.firstElementChild);
                  Severity: Major
                  Found in src/EditorArticulacaoController.js - About 45 mins to fix

                    Function criarRotuloLexML has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function criarRotuloLexML(tipo, numero, unico, nEmenda, rotulos) {
                    Severity: Minor
                    Found in src/lexml/exportarParaLexML.js - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language