xylabs/sdk-js

View on GitHub

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 */
Severity: Minor
Found in packages/threads/src/master/pool.ts - About 2 hrs to fix

    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]
    Severity: Minor
    Found in packages/jest-helpers/src/tags/filter.ts - 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 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,
    Severity: Minor
    Found in packages/object/src/AsTypeFactory.ts - 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 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> = []
    
    
    Severity: Major
    Found in packages/threads/src/master/implementation.node.ts - About 2 hrs to fix

      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
      
      
      Severity: Major
      Found in packages/threads/src/master/implementation.node.ts - About 2 hrs to fix

        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) => {
        Severity: Minor
        Found in packages/function-name/src/functionName.ts - 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 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) => {
        Severity: Minor
        Found in packages/logger/src/getFunctionName.ts - 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 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) => {
        Severity: Minor
        Found in packages/threads/src/master/invocation-proxy.ts - About 1 hr to fix

          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 {
          Severity: Minor
          Found in packages/threads/src/master/implementation.browser.ts - About 1 hr to fix

            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.')
            Severity: Minor
            Found in packages/threads/src/master/pool.ts - About 1 hr to fix

              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 {
              Severity: Minor
              Found in packages/threads/src/master/implementation.browser.ts - 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 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,
              Severity: Minor
              Found in packages/object/src/AsTypeFactory.ts - About 1 hr to fix

                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
                
                
                Severity: Minor
                Found in packages/threads/src/master/implementation.node.ts - 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 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) {
                Severity: Minor
                Found in packages/threads/src/worker/index.ts - About 1 hr to fix

                  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)
                  Severity: Minor
                  Found in packages/threads/src/observable-promise.ts - About 1 hr to fix

                    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 () => {
                    Severity: Minor
                    Found in packages/forget/src/forget.ts - About 1 hr to fix

                      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> = []
                      
                      
                      Severity: Minor
                      Found in packages/threads/src/master/implementation.node.ts - 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 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
                      Severity: Minor
                      Found in packages/hex/src/assert.ts - 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 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)) {
                      Severity: Minor
                      Found in packages/threads/src/master/invocation-proxy.ts - About 1 hr to fix

                        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)
                        Severity: Minor
                        Found in packages/threads/src/worker/index.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language