packages/postcss-ekscss/src/tokenize.ts
Function tokenize
has a Cognitive Complexity of 128 (exceeds 5 allowed). Consider refactoring. Wontfix
Wontfix
export function tokenize(
input: Input & { error: (message: string, pos?: number) => void },
options: TokenizeOptions = {},
): Tokenizer {
const css = input.css.valueOf();
- 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 tokenize
has 239 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
Wontfix
export function tokenize(
input: Input & { error: (message: string, pos?: number) => void },
options: TokenizeOptions = {},
): Tokenizer {
const css = input.css.valueOf();
Function nextToken
has 176 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
Wontfix
function nextToken(opts?: { ignoreUnclosed?: boolean }): Token | void {
if (returned.length > 0) return returned.pop();
if (pos >= len) return undefined;
const ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
File tokenize.ts
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
Wontfix
// Based on https://github.com/postcss/postcss-scss/blob/e57f9bdfdfaf49ae72f379f968d43c441fd77d18/lib/scss-tokenize.js
// TODO: Tokenize xcss tagged template literals within XCSS expressions
/* eslint-disable unicorn/prefer-code-point */
Consider simplifying this complex logical expression. Wontfix
Wontfix
if (
escape &&
code !== SLASH &&
code !== SPACE &&
code !== NEWLINE &&
Avoid deeply nested control flow statements. Wontfix
Wontfix
if (brackets === 0) break;