jeffijoe/awilix

View on GitHub

Showing 26 of 80 total issues

File container.test.ts has 821 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { throws } from 'smid'
import * as util from 'util'
import { createContainer, AwilixContainer } from '../container'
import { Lifetime } from '../lifetime'
import { AwilixResolutionError } from '../errors'
Severity: Major
Found in src/__tests__/container.test.ts - About 1 day to fix

    Function createContainerInternal has 282 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createContainerInternal<
      T extends object = any,
      U extends object = any,
    >(
      options: ContainerOptions,
    Severity: Major
    Found in src/container.ts - About 1 day to fix

      Function createTokenizer has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
      Open

      export function createTokenizer(source: string) {
        const end = source.length
        let pos: number = 0
        let type: TokenType = 'EOF'
        let value: string = ''
      Severity: Minor
      Found in src/function-tokenizer.ts - About 1 day 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 createContainerInternal has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
      Open

      function createContainerInternal<
        T extends object = any,
        U extends object = any,
      >(
        options: ContainerOptions,
      Severity: Minor
      Found in src/container.ts - About 1 day 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 createTokenizer has 157 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function createTokenizer(source: string) {
        const end = source.length
        let pos: number = 0
        let type: TokenType = 'EOF'
        let value: string = ''
      Severity: Major
      Found in src/function-tokenizer.ts - About 6 hrs to fix

        File load-modules.test.ts has 420 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import * as path from 'path'
        import { loadModules, LoadModulesOptions } from '../load-modules'
        import { createContainer } from '../container'
        import { Lifetime } from '../lifetime'
        import { InjectionMode } from '../injection-mode'
        Severity: Minor
        Found in src/__tests__/load-modules.test.ts - About 6 hrs to fix

          File container.ts has 372 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import * as util from 'util'
          import {
            AwilixRegistrationError,
            AwilixResolutionError,
            AwilixTypeError,
          Severity: Minor
          Found in src/container.ts - About 4 hrs to fix

            Function parseParameterList has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

            export function parseParameterList(source: string): Array<Parameter> | null {
              const { next: _next, done } = createTokenizer(source)
              const params: Array<Parameter> = []
            
              let t: Token = null!
            Severity: Minor
            Found in src/param-parser.ts - About 4 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 resolve has 90 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function resolve(name: string | symbol, resolveOpts?: ResolveOptions): any {
                resolveOpts = resolveOpts || {}
            
                try {
                  // Grab the registration by name.
            Severity: Major
            Found in src/container.ts - About 3 hrs to fix

              Function parseParameterList has 85 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function parseParameterList(source: string): Array<Parameter> | null {
                const { next: _next, done } = createTokenizer(source)
                const params: Array<Parameter> = []
              
                let t: Token = null!
              Severity: Major
              Found in src/param-parser.ts - About 3 hrs to fix

                File param-parser.test.ts has 284 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { parseParameterList } from '../param-parser'
                
                describe('parseParameterList', () => {
                  it('returns an empty array when invalid input is given', () => {
                    expect(parseParameterList('')).toEqual([])
                Severity: Minor
                Found in src/__tests__/param-parser.test.ts - About 2 hrs to fix

                  File resolvers.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { AwilixContainer, FunctionReturning, ResolveOptions } from './container'
                  import { AwilixTypeError } from './errors'
                  import { InjectionMode, InjectionModeType } from './injection-mode'
                  import { Lifetime, LifetimeType } from './lifetime'
                  import { Parameter, parseParameterList } from './param-parser'
                  Severity: Minor
                  Found in src/resolvers.ts - About 2 hrs to fix

                    Function advance has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function advance() {
                        value = ''
                        type = 'EOF'
                        // eslint-disable-next-line no-constant-condition
                        while (true) {
                    Severity: Major
                    Found in src/function-tokenizer.ts - About 2 hrs to fix

                      Function createInjectorProxy has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function createInjectorProxy<T extends object>(
                        container: AwilixContainer<T>,
                        injector: InjectorFunction,
                      ) {
                        const locals = injector(container) as any
                      Severity: Minor
                      Found in src/resolvers.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 registerDescriptor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function registerDescriptor<ESM extends boolean = false>(
                        container: AwilixContainer,
                        opts: LoadModulesOptions<ESM>,
                        moduleDescriptor: LoadedModuleDescriptor & { value: any },
                      ) {
                      Severity: Minor
                      Found in src/load-modules.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 createInjectorProxy has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function createInjectorProxy<T extends object>(
                        container: AwilixContainer<T>,
                        injector: InjectorFunction,
                      ) {
                        const locals = injector(container) as any
                      Severity: Minor
                      Found in src/resolvers.ts - About 1 hr to fix

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

                        function generateResolve(fn: Function, dependencyParseTarget?: Function) {
                          // If the function used for dependency parsing is falsy, use the supplied function
                          if (!dependencyParseTarget) {
                            dependencyParseTarget = fn
                          }
                        Severity: Minor
                        Found in src/resolvers.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 parseLoadedModule has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function parseLoadedModule(
                          loaded: any,
                          m: ModuleDescriptor,
                        ): Array<LoadedModuleDescriptor> {
                          const items: Array<LoadedModuleDescriptor> = []
                        Severity: Minor
                        Found in src/load-modules.ts - About 1 hr to fix

                          Function registerDescriptor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function registerDescriptor<ESM extends boolean = false>(
                            container: AwilixContainer,
                            opts: LoadModulesOptions<ESM>,
                            moduleDescriptor: LoadedModuleDescriptor & { value: any },
                          ) {
                          Severity: Minor
                          Found in src/load-modules.ts - About 1 hr to fix

                            Function generateResolve has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function generateResolve(fn: Function, dependencyParseTarget?: Function) {
                              // If the function used for dependency parsing is falsy, use the supplied function
                              if (!dependencyParseTarget) {
                                dependencyParseTarget = fn
                              }
                            Severity: Minor
                            Found in src/resolvers.ts - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language