Showing 43 of 76 total issues
File pool.ts
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable unicorn/no-thenable */
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable require-await */
/* eslint-disable @typescript-eslint/member-ordering */
/* eslint-disable unicorn/no-array-reduce */
Function matchFilter
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
(strParam = '') =>
(tags: string[]) => {
const str = strParam.trim()
if (typeof tags === 'string') {
tags = [tags]
- 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 create
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
create: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => {
function func<TType extends T>(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: AnyNonPromise,
config?: TypeCheckConfig,
- 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 initTinyWorker
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initTinyWorker(): ImplementationExport {
const TinyWorker = require('tiny-worker')
let allWorkers: Array<typeof TinyWorker> = []
Function initWorkerThreadsWorker
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initWorkerThreadsWorker(): ImplementationExport {
// Webpack hack
const NativeWorker =
typeof __non_webpack_require__ === 'function' ? __non_webpack_require__('worker_threads').Worker : eval('require')('worker_threads').Worker
Function functionName
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export const functionName = (depth = 2) => {
try {
throw new Error('Getting function name')
} catch (ex) {
return handleError(ex, (error) => {
- 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 getFunctionName
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export const getFunctionName = (depth = 2) => {
try {
throw new Error('Getting function name')
} catch (ex) {
return handleError(ex, (error) => {
- 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 createObservableForJob
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createObservableForJob<ResultType>(worker: WorkerType, jobUID: number): Observable<ResultType> {
return new Observable((observer) => {
let asyncType: 'observable' | 'promise' | undefined
const messageHandler = ((event: MessageEvent) => {
Function selectWorkerImplementation
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function selectWorkerImplementation(): ImplementationExport {
if (typeof Worker === 'undefined') {
// Might happen on Safari, for instance
// The idea is to only fail if the constructor is actually used
return class NoWebWorker {
Function queue
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
queue(taskFunction: TaskRunFunction<ThreadType, any>) {
const { maxQueuedJobs = Number.POSITIVE_INFINITY } = this.options
if (this.isClosing) {
throw new Error('Cannot schedule pool tasks after terminate() has been called.')
Function selectWorkerImplementation
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function selectWorkerImplementation(): ImplementationExport {
if (typeof Worker === 'undefined') {
// Might happen on Safari, for instance
// The idea is to only fail if the constructor is actually used
return class NoWebWorker {
- 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 create
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
create: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => {
function func<TType extends T>(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: AnyNonPromise,
config?: TypeCheckConfig,
Function initWorkerThreadsWorker
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function initWorkerThreadsWorker(): ImplementationExport {
// Webpack hack
const NativeWorker =
typeof __non_webpack_require__ === 'function' ? __non_webpack_require__('worker_threads').Worker : eval('require')('worker_threads').Worker
- 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 expose
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function expose(exposed: WorkerFunction | WorkerModule<any>) {
if (!Implementation.isWorkerRuntime()) {
throw new Error('expose() called in the master thread.')
}
if (exposeCalled) {
Function then
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
then<TResult1 = T, TResult2 = never>(
onFulfilledRaw?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
onRejectedRaw?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
): Promise<TResult1 | TResult2> {
const onFulfilled: OnFulfilled<T, TResult1> = onFulfilledRaw || (returnInput as any)
Function forget
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
forget<T>(promise: Promise<T>, config?: ForgetTimeoutConfig) {
let completed = false
this.activeForgets++
const promiseWrapper = async () => {
Function initTinyWorker
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function initTinyWorker(): ImplementationExport {
const TinyWorker = require('tiny-worker')
let allWorkers: Array<typeof TinyWorker> = []
- 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 assertError
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export const assertError = (value: unknown, assert: AssertConfig | undefined, defaultMessage: string) => {
if (assert) {
const assertString =
typeof assert === 'string' ? assert
: typeof assert === 'boolean' ? defaultMessage
- 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 messageHandler
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const messageHandler = ((event: MessageEvent) => {
debugMessages('Message from worker:', event.data)
if (!event.data || event.data.uid !== jobUID) return
if (isJobStartMessage(event.data)) {
Function runFunction
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function runFunction(jobUID: number, fn: WorkerFunction, args: any[]) {
let syncResult: any
try {
syncResult = fn(...args)