File EditorArticulacaoController.js
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Copyright 2017 Assembleia Legislativa de Minas Gerais
*
* This file is part of Editor-Articulacao.
*
* Editor-Articulacao is free software: you can redistribute it and/or modify
Function obterSelecao
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
function obterSelecao(ctrl) {
var selecao = ctrl.getSelection();
var range = selecao && selecao.rangeCount > 0 ? selecao.getRangeAt(0) : null;
if (range) {
- Read upRead up
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 a Cognitive Complexity of 19 (exceeds 5 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') {
- Read upRead up
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
EditorArticulacaoController
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class EditorArticulacaoController {
/**
* Elemento do DOM que será utilizado como editor de articulação.
*
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) {
Function atualizarContexto
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
atualizarContexto() {
var elementoSelecionado = obterSelecao(this);
if (!elementoSelecionado) {
if (!this.contexto) {
- Read upRead up
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 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.';
}
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
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.';
}
- Read upRead up
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.';
- Read upRead up
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;
}
- Read upRead up
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
- Read upRead up
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') {
Avoid deeply nested control flow statements. Open
do {
startContainer = startContainer.firstElementChild;
} while (startContainer.firstElementChild);
Function lexml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
get lexml() {
try {
return this.vazio ? document.createDocumentFragment() : exportarParaLexML(this._elemento, this.opcoes.rotulo);
} catch (e) {
if (e instanceof ArticulacaoInvalidaException) {
- Read upRead up
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 lexml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
set lexml(valor) {
let articulacao = importarDeLexML(valor);
this._elemento.innerHTML = '';
this._elemento.appendChild(articulacao);
- Read upRead up
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"