krux/postscribe

View on GitHub

Showing 12 of 12 total issues

Function _buildChunk has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  _buildChunk(tokens) {
    let nextId = this.actuals.length;

    // The raw html of this chunk.
    const raw = [];
Severity: Minor
Found in src/write-stream.js - About 3 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

File write-stream.js has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import HtmlParser from 'prescribe';
import * as utils from './utils';

/**
 * Turn on to debug how each chunk affected the DOM.
Severity: Minor
Found in src/write-stream.js - About 3 hrs to fix

Function _scriptLoadHandler has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  _scriptLoadHandler(el, done) {
    function cleanup() {
      el = el.onload = el.onreadystatechange = el.onerror = null;
    }

Severity: Minor
Found in src/write-stream.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 _scriptLoadHandler has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _scriptLoadHandler(el, done) {
    function cleanup() {
      el = el.onload = el.onreadystatechange = el.onerror = null;
    }

Severity: Major
Found in src/write-stream.js - About 2 hrs to fix

Function runStream has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function runStream(el, html, options) {
  active = new WriteStream(el, options);

  // Identify this stream.
  active.id = nextId++;
Severity: Minor
Found in src/postscribe.js - About 1 hr to fix

Function _buildChunk has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _buildChunk(tokens) {
    let nextId = this.actuals.length;

    // The raw html of this chunk.
    const raw = [];
Severity: Minor
Found in src/write-stream.js - About 1 hr to fix

Function postscribe has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function postscribe(el, html, options) {
  if (utils.isFunction(options)) {
    options = {done: options};
  } else if (options === 'clear') {
    queue = [];
Severity: Minor
Found in src/postscribe.js - About 1 hr to fix

Function postscribe has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export default function postscribe(el, html, options) {
  if (utils.isFunction(options)) {
    options = {done: options};
  } else if (options === 'clear') {
    queue = [];
Severity: Minor
Found in src/postscribe.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 _walkChunk has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  _walkChunk() {
    let node;
    const stack = [this.proxyRoot];

    // use shift/unshift so that children are walked in document order
Severity: Minor
Found in src/write-stream.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

Function _writeImpl has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  _writeImpl(html) {
    this.parser.append(html);

    let tok;
    let script;
Severity: Minor
Found in src/write-stream.js - About 35 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 _writeScriptToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  _writeScriptToken(tok, done) {
    const el = this._buildScript(tok);
    const asyncRelease = this._shouldRelease(el);
    const afterAsync = this.options.afterAsync;

Severity: Minor
Found in src/write-stream.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 _handleScriptToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  _handleScriptToken(tok) {
    const remainder = this.parser.clear();

    if (remainder) {
      // Write remainder immediately behind this script.
Severity: Minor
Found in src/write-stream.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