Function splitMarkdownBlocks
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
splitMarkdownBlocks(text) {
let blocks = [];
// TODO: consolidate following + methods/closures with splitHtmlBlocks()
// NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
- 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 splitHtmlBlocks
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
splitHtmlBlocks(text) {
let blocks = [];
// TODO: consolidate following + methods/closures with splitMarkdownBlocks()
// NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
- 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 LabelSplitter.js
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
let LabelAccumulator = require('./LabelAccumulator').default;
let ComponentUtil = require('./ComponentUtil').default;
/**
Function process
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
process(text) {
if (!ComponentUtil.isValidLabel(text)) {
return this.lines.finalize();
}
- 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 splitMarkdownBlocks
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
splitMarkdownBlocks(text) {
let blocks = [];
// TODO: consolidate following + methods/closures with splitHtmlBlocks()
// NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
Function splitHtmlBlocks
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
splitHtmlBlocks(text) {
let blocks = [];
// TODO: consolidate following + methods/closures with splitMarkdownBlocks()
// NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
Function process
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
process(text) {
if (!ComponentUtil.isValidLabel(text)) {
return this.lines.finalize();
}
Function splitStringIntoLines
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
splitStringIntoLines(str, mod = 'normal', appendLast = false) {
// Still-present spaces are relevant, retain them
str = str.replace(/^( +)/g, '$1\r');
str = str.replace(/([^\r][^ ]*)( +)/g, '$1\r$2\r');
let words = str.split('\r');
- 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 splitStringIntoLines
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
splitStringIntoLines(str, mod = 'normal', appendLast = false) {
// Still-present spaces are relevant, retain them
str = str.replace(/^( +)/g, '$1\r');
str = str.replace(/([^\r][^ ]*)( +)/g, '$1\r$2\r');
let words = str.split('\r');
Avoid deeply nested control flow statements. Open
if (/</.test(text.substr(s.position,4))) {
s.add("<");
s.position += 3;
} else if (/&/.test(text.substr(s.position,5))) {
s.add("&");
Avoid deeply nested control flow statements. Open
} else if (!s.mono && (s.mod() === "ital") && /\_/.test(ch)) {
if ((s.position === text.length-1) || /[.,*` \t\n]/.test(text.charAt(s.position+1))) {
s.emitBlock();
s.ital = false;
s.modStack.shift();
Avoid deeply nested control flow statements. Open
if (/ \t/.test(ch)) {
s.spacing = true;
} else {
s.add(ch);
s.beginable = false;
Avoid deeply nested control flow statements. Open
if ((s.position === text.length-1) || /[.,_` \t\n]/.test(text.charAt(s.position+1))) {
s.emitBlock();
s.bold = false;
s.modStack.shift();
} else {
Avoid too many return
statements within this function. Open
return 'ital';
Avoid too many return
statements within this function. Open
return 'ital';
TODO found Open
// TODO: consolidate following + methods/closures with splitHtmlBlocks()
- Exclude checks
TODO found Open
// TODO: This can be done more efficiently with caching
- Exclude checks
TODO found Open
// TODO: consolidate following + methods/closures with splitMarkdownBlocks()
- Exclude checks