Showing 55 of 85 total issues
Function constructor
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
constructor (options) {
this.whitespaceChars = (options.preserveNewlines)
? options.whitespaceCharacters.replace(/\n/g, '')
: options.whitespaceCharacters;
const whitespaceCodes = charactersToCodes(this.whitespaceChars);
- 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 tableToString
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
function tableToString (tableRows, rowSpacing, colSpacing) {
const layout = [];
let colNumber = 0;
const rowNumber = tableRows.length;
const rowOffsets = [0];
- 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
File md-formatters.js
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { get, trimCharacter, trimCharacterEnd } from '@html-to-text/base/src/util';
import { render } from 'dom-serializer';
import { existsOne, innerText } from 'domutils';
BlockTextBuilder
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class BlockTextBuilder {
/**
* Creates an instance of BlockTextBuilder.
*
Function formatDataTable
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function formatDataTable (elem, walk, builder, formatOptions) {
builder.openTable();
elem.children.forEach(walkTable);
builder.closeTable({
tableToString: (rows) => tableToString(rows, formatOptions.rowSpacing ?? 0, formatOptions.colSpacing ?? 3),
- 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 splitLongWord
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
splitLongWord (word) {
const parts = [];
let idx = 0;
while (word.length > this.maxLineLength) {
- 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
File text-formatters.js
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { get, numberToLetterSequence, numberToRoman, trimCharacter, trimCharacterEnd } from '@html-to-text/base/src/util';
import { tableToString } from './table-printer';
Function constructor
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (options) {
this.whitespaceChars = (options.preserveNewlines)
? options.whitespaceCharacters.replace(/\n/g, '')
: options.whitespaceCharacters;
const whitespaceCodes = charactersToCodes(this.whitespaceChars);
Function formatDataTable
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function formatDataTable (elem, walk, builder, formatOptions) {
builder.openTable();
elem.children.forEach(walkTable);
builder.closeTable({
tableToString: (rows) => tableToString(rows, formatOptions.rowSpacing ?? 0, formatOptions.colSpacing ?? 3),
File block-text-builder.js
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
// eslint-disable-next-line no-unused-vars
StackItem, BlockStackItem,
TableCellStackItem, TableRowStackItem, TableStackItem,
Function tableToString
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function tableToString (tableRows, rowSpacing, colSpacing) {
const layout = [];
let colNumber = 0;
const rowNumber = tableRows.length;
const rowOffsets = [0];
Function collectDefinitionGroups
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function collectDefinitionGroups (elem) {
const defItems = [];
function handleDtDd (el) {
if (el.name === 'dt' || el.name === 'dd') {
defItems.push(el);
- 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 formatDataTable
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function formatDataTable (elem, walk, builder, formatOptions) {
builder.openTable();
elem.children.forEach(walkTable);
const hasHeader = existsOne(
(el) => el.name === 'thead' || el.name === 'th',
- 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 handleDeprecatedOptions
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function handleDeprecatedOptions (options) {
if (options.tags) {
const tagDefinitions = Object.entries(options.tags).map(
([selector, definition]) => ({ ...definition, selector: selector || '*' })
);
- 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 formatDataTable
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function formatDataTable (elem, walk, builder, formatOptions) {
builder.openTable();
elem.children.forEach(walkTable);
const hasHeader = existsOne(
(el) => el.name === 'thead' || el.name === 'th',
Function findBases
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function findBases (dom, options, baseSelectorsPicker) {
const results = [];
function recursiveWalk (walk, /** @type { DomNode[] } */ dom) {
dom = dom.slice(0, options.limits.maxChildNodes);
- 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 formatAnchor
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function formatAnchor (elem, walk, builder, formatOptions) {
function getHref () {
if (formatOptions.ignoreHref) { return ''; }
if (!elem.attribs || !elem.attribs.href) { return ''; }
let href = elem.attribs.href.replace(/^mailto:/, '');
- 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 tableToString
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function tableToString (tableRows, firstRowIsHeader, spanMode) {
if (
spanMode === 'tag' &&
tableRows.some(r => r[0] && (r[0].colspan > 1 || r[0].rowspan > 1))
) {
Function addLiteral
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
addLiteral (text, inlineTextBuilder, noWrap = true) {
if (!text) { return; }
const previouslyStashedSpace = inlineTextBuilder.stashedSpace;
let anyMatch = false;
let m = this.newlineOrNonNewlineStringRe.exec(text);
- 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 walkTable
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function walkTable (elem) {
if (elem.type !== 'tag') { return; }
const formatHeaderCell = (formatOptions.uppercaseHeaderCells !== false)
? (cellNode) => {