MaxMilton/ekscss

View on GitHub
packages/postcss-ekscss/src/tokenize.ts

Summary

Maintainability
A
0 mins
Test Coverage

Function tokenize has a Cognitive Complexity of 128 (exceeds 5 allowed). Consider refactoring.
Wontfix

export function tokenize(
  input: Input & { error: (message: string, pos?: number) => void },
  options: TokenizeOptions = {},
): Tokenizer {
  const css = input.css.valueOf();
Severity: Minor
Found in packages/postcss-ekscss/src/tokenize.ts - About 2 days to fix

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

export function tokenize(
  input: Input & { error: (message: string, pos?: number) => void },
  options: TokenizeOptions = {},
): Tokenizer {
  const css = input.css.valueOf();
Severity: Major
Found in packages/postcss-ekscss/src/tokenize.ts - About 1 day to fix

    Function nextToken has 176 lines of code (exceeds 25 allowed). Consider refactoring.
    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;
    Severity: Major
    Found in packages/postcss-ekscss/src/tokenize.ts - About 7 hrs to fix

      File tokenize.ts has 287 lines of code (exceeds 250 allowed). Consider refactoring.
      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 */
      Severity: Minor
      Found in packages/postcss-ekscss/src/tokenize.ts - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Wontfix

                if (
                  escape &&
                  code !== SLASH &&
                  code !== SPACE &&
                  code !== NEWLINE &&
        Severity: Major
        Found in packages/postcss-ekscss/src/tokenize.ts - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Wontfix

                        if (brackets === 0) break;
          Severity: Major
          Found in packages/postcss-ekscss/src/tokenize.ts - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status