belsrc/worker-promise

View on GitHub

Showing 8 of 8 total issues

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

const promiseWorker = (worker, val) =>
  // eslint-disable-next-line promise/prefer-await-to-then
  Promise.resolve().then(() =>
    new Promise((resolve, reject) => {
      try {
Severity: Minor
Found in src/index.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 callbackWorker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const callbackWorker = (worker, val, fn) => {
  try {
    worker.addEventListener('message', ({ data }) => {
      if(data.error) {
        return fn(isString(data.error) ? new Error(data.error) : createError(data.error), data);
Severity: Minor
Found in src/index.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

Parsing error: The keyword 'import' is reserved
Open

import './consumer';
Severity: Minor
Found in example/prime-numbers/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const getPrimes = (max) => {
Severity: Minor
Found in example/prime-numbers/prime-num.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'import' is reserved
Open

import workerPromise from '../../src';
Severity: Minor
Found in example/prime-numbers/consumer.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const isString = value => value != null && value.constructor === String;
Severity: Minor
Found in src/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'import' is reserved
Open

import '@babel/register';
Severity: Minor
Found in src/worker-promise.test.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'import' is reserved
Open

import getPrimes from './prime-num';

For more information visit Source: http://eslint.org/docs/rules/

Severity
Category
Status
Source
Language