src/compiler/parser/html-parser.js
Function parseHTML
has a Cognitive Complexity of 162 (exceeds 5 allowed). Consider refactoring. Open
Open
export function parseHTML (html, options) {
const stack = []
const expectHTML = options.expectHTML
const isUnaryTag = options.isUnaryTag || no
const canBeLeftOpenTag = options.canBeLeftOpenTag || no
- 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 parseHTML
has 214 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function parseHTML (html, options) {
const stack = []
const expectHTML = options.expectHTML
const isUnaryTag = options.isUnaryTag || no
const canBeLeftOpenTag = options.canBeLeftOpenTag || no
Function parseEndTag
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function parseEndTag (tagName, start, end) {
let pos, lowerCasedTagName
if (start == null) start = index
if (end == null) end = index
Function handleStartTag
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function handleStartTag (match) {
const tagName = match.tagName
const unarySlash = match.unarySlash
if (expectHTML) {
Avoid deeply nested control flow statements. Open
Open
if (commentEnd >= 0) {
if (options.shouldKeepComment) {
options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3)
}
advance(commentEnd + 3)
Avoid deeply nested control flow statements. Open
Open
if (conditionalEnd >= 0) {
advance(conditionalEnd + 2)
continue
}
Avoid deeply nested control flow statements. Open
Open
if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
advance(1)
}
Avoid deeply nested control flow statements. Open
Open
if (next < 0) break