krux/prescribe

View on GitHub

Showing 9 of 9 total issues

Function _peekTokenImpl has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  _peekTokenImpl() {
    for (let type in detect) {
      if (detect.hasOwnProperty(type)) {
        if (detect[type].test(this.stream)) {
          const token = streamReaders[type](this.stream);
Severity: Minor
Found in src/HtmlParser.js - About 2 hrs 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 fixedReadTokenFactory has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

export default function fixedReadTokenFactory(parser, options, readTokenImpl) {
  const stack = newStack();

  const handlers = {
    startTag(tok) {
Severity: Minor
Found in src/fixedReadTokenFactory.js - About 2 hrs 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 fixedReadTokenFactory has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function fixedReadTokenFactory(parser, options, readTokenImpl) {
  const stack = newStack();

  const handlers = {
    startTag(tok) {
Severity: Minor
Found in src/fixedReadTokenFactory.js - About 1 hr to fix

    Function formatTag has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      static formatTag(tok, content = null) {
        let str = `<${tok.tagName}`;
        for (let key in tok.attrs) {
          if (tok.attrs.hasOwnProperty(key)) {
            str += ` ${key}`;
    Severity: Minor
    Found in src/tokens.js - About 1 hr 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 constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor(stream = '', options = {}) {
        this.stream = stream;
    
        let fix = false;
        const fixedTokenOptions = {};
    Severity: Minor
    Found in src/HtmlParser.js - About 55 mins 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

    Avoid deeply nested control flow statements.
    Open

                if (token.type === 'startTag' &&
                    (/script|style/i).test(token.tagName)) {
                  return null;
                } else {
                  token.text = this.stream.substr(0, token.length);
    Severity: Major
    Found in src/HtmlParser.js - About 45 mins to fix

      Consider simplifying this complex logical expression.
      Open

              } else if (arguments[5]) {
                attrs[arguments[5]] = '';
                booleanAttrs[arguments[5]] = true;
              } else {
                attrs[name] = arguments[2] || arguments[3] || arguments[4] ||
      Severity: Major
      Found in src/streamReaders.js - About 40 mins to fix

        Function newStack has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function newStack() {
          const stack = [];
        
          stack.last = function() {
            return this[this.length - 1];
        Severity: Minor
        Found in src/fixedReadTokenFactory.js - About 25 mins 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 atomicTag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function atomicTag(stream) {
          const start = startTag(stream);
          if (start) {
            const rest = stream.slice(start.length);
            // for optimization, we check first just for the end tag
        Severity: Minor
        Found in src/streamReaders.js - About 25 mins 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

        Severity
        Category
        Status
        Source
        Language