Showing 19 of 27 total issues
Consider simplifying this complex logical expression. Open
if (mEmenda) {
const mEmendaAnterior = anterior ? /^(.+?)(?:-([a-z]))?$/i.exec(anterior.numero || '') : null;
sequenciaNumericaValida = !!mEmendaAnterior && mEmenda[1] === mEmendaAnterior[1] &&
(!mEmendaAnterior[2] && mEmenda[2].toUpperCase() === 'A' ||
Function escapar
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
escapar(texto: string, substituir: SubstituirCallback): string {
const regexpAspas = /[“”‘’"]/g;
let resultado = '';
let ultimo = 0;
let abertura: number;
- 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 interpretarArticulacao
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function interpretarArticulacao(textoOriginal: string,
opcoes: IOpcoesInterpretacao = {}): IArticulacaoInterpretada {
const contexto = new Contexto();
const regexpLinhas: IParserLinha[] = [
...(opcoes.parsersExtras ?? []),
- 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 escapar
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
escapar(texto: string, substituir: SubstituirCallback): string {
const regexpAspas = /[“”‘’"]/g;
let resultado = '';
let ultimo = 0;
let abertura: number;
Function verificarNumeracao
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function verificarNumeracao(dispositivo: QualquerDispositivo,
anterior: QualquerDispositivo | undefined,
formatacao: FormatacaoNumerica) {
const mEmenda = /^(.+?)-([a-z])$/i.exec(dispositivo.numero || '');
let sequenciaNumericaValida: boolean;
- 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 interpretarArticulacao
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function interpretarArticulacao(textoOriginal: string,
opcoes: IOpcoesInterpretacao = {}): IArticulacaoInterpretada {
const contexto = new Contexto();
const regexpLinhas: IParserLinha[] = [
...(opcoes.parsersExtras ?? []),
Function desfazerEscapes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
desfazerEscapes(trecho?: string): string | void {
if (!this.contexto) {
throw new Error('Contexto de escapamento está nulo.');
}
- 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 validarArticulacao
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function validarArticulacao(dispositivosOriginais: QualquerDispositivo[],
opcoes: IOpcoesValidacao = {}): Validacao[] {
let ultimoArtigo: Artigo;
function _validarArticulacao(dispositivos: QualquerDispositivo[]) {
Function _validarArticulacao
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _validarArticulacao(dispositivos: QualquerDispositivo[]) {
const ultimos: { [tipo in TipoDispositivoOuAgrupador]?: QualquerDispositivo } = {
get artigo() { return ultimoArtigo; },
set artigo(artigo) { ultimoArtigo = artigo; }
};
Function desfazerEscapes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
desfazerEscapes(trecho?: string): string | void {
if (!this.contexto) {
throw new Error('Contexto de escapamento está nulo.');
}
Function constructor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(textoOriginal: string, ...escapesExtras: EscapeInterpretacao[]) {
const escapadores = [new EscapeSimboloEscape(), ...escapesExtras];
/*
* Para cada citação, isto é, texto entre aspas, substitui-se o seu conteúdo
Function textoEscapado
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.textoEscapado = escapadores.reduce((prev, cur) => {
const escapesAnteriores = [...this.escapes];
/**
* Determina o índice em que deve inserir o escape de forma ordenada
Function onMatch
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
onMatch(contexto: Contexto, m: RegExpExecArray): Dispositivo<any> | null {
const numero = m[1];
if (numero.length === 1 && contexto.ultimoItem && contexto.ultimoItem instanceof Alinea) {
// Pode ser que, na verdade, trata-se de uma alínea sendo confundida com um inciso.
- 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 validarConteudo
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function validarConteudo(dispositivo: QualquerDispositivo,
proximo: QualquerDispositivo | undefined,
escapes: EscapeInterpretacao[]): boolean {
const conteudoParaValidacao =
escapes.reduce((prev, cur) => cur.escapar(prev, () => ''), dispositivo.descricao)
- 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 interpretarNumeroRomano
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export function interpretarNumeroRomano(romano: string) {
romano = romano.toUpperCase().replace(/ +/g, '');
let soma = 0;
let i = 0;
const mapa = { M: 1000, D: 500, C: 100, L: 50, X: 10, V: 5, I: 1 };
- 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 onMatch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
onMatch(contexto: Contexto, m: RegExpExecArray): Dispositivo<any> | null {
if (m[2] === '.' && m[1].length > 1 &&
(contexto.ultimoItem?.tipo !== TipoDispositivo.ALINEA ||
!contexto.ultimoItem.numero ||
interpretarLetra(contexto.ultimoItem.numero) !== interpretarLetra(m[1]) - 1)) {
- 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 processar
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public processar(contexto: Contexto, linha: string): boolean {
if (this.atendeRequisitos(contexto)) {
const m = this.regexp.exec(linha);
if (m) {
- 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 inferirFormatacao
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function inferirFormatacao(numero: string | null): FormatacaoNumerica {
if (!numero) {
return FormatacaoNumerica.NENHUMA;
}
- 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 onMatch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
onMatch(contexto: Contexto, m: RegExpExecArray): Dispositivo<any> | null {
const item = new Item(m[1], m[2]);
let container = contexto.getUltimoItemTipo(Alinea);
if (!container) {
- 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"