src/utils/text-helper.js
File text-helper.js
has 264 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
let dummyContext;
function setDummyContext() {
dummyContext = dummyContext || document.createElement('canvas').getContext('2d');
}
Consider simplifying this complex logical expression. Open
Open
if (Array.isArray(maxNumLines)) {
maxNumLines.forEach((v) => {
totalMaxNumLines += Number.isNaN(v) || v <= 0 || !v ? 0 : v;
});
Function tokenize
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
tokenize(text, font, ellipsis, maxNumLines, maxWidth, maxHeight, lineHeightMultiplicator = 1) {
Avoid deeply nested control flow statements. Open
Open
if (
textHelper.measureTextWidth(`${remainder} ${cLines[i + 1]}`) > width &&
result.length + cLines.length - i <= maxNumLines
) {
// If adding to the next line will force that to break as well and we are not close to the max limit, then create a new line inbetween instead
Function wrapText
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
wrapText(text, maxWidth, font, maxNumLines, ellipsis) {
Function wordWrap
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
wordWrap(lines, width, font, maxNumLines, ellipsis) {