maxgherman/TypeIOC

View on GitHub

Showing 22 of 52 total issues

RegistrationBase has 36 functions (exceeds 20 allowed). Consider refactoring.
Open

export class RegistrationBase implements IRegistrationBase {
    private _id: string
    private _factory?: Factory<{}>
    private _factoryType?: {}
    private _factoryValue?: {}
Severity: Minor
Found in src/registration/base.ts - About 4 hrs to fix

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

    import { IRegistrationBase, IDynamicDependency } from '../registration'
    import { ResolutionError, CircularDependencyError } from '../exceptions/index.js'
    import { owner, scope } from '../common/index.js'
    import {
        IRegistrationStorageService,
    Severity: Minor
    Found in src/build/internal-container.ts - About 3 hrs to fix

      Function container has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const container = (_container: IInternalContainer) => {
          const result: IContainer = {
              get cache(): ICache {
                  return _container.cache
              },
      Severity: Major
      Found in src/build/container.ts - About 3 hrs to fix

        InternalContainer has 29 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class InternalContainer implements IInternalContainer {
        
            private _parent: InternalContainer | undefined
            private _children: InternalContainer [] = []
            private _pendingResolutions: IndexedCollection<boolean>
        Severity: Minor
        Found in src/build/internal-container.ts - About 3 hrs to fix

          Function instantiateByDependencies has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              private instantiateByDependencies(type: {}, dependencies: {}[]) {
                  const params = dependencies
                  .map((dependency, index) => {
          
                      const depParams =
          Severity: Minor
          Found in src/build/invoker.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 defineWrapStrategies has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private defineWrapStrategies(): IStrategy {
                  const result = <IStrategy>{}
                  const createCallChainFromList = this.createCallChainFromList.bind(this)
                  const defineWrapGetter = this.defineWrapGetter.bind(this)
                  const defineWrapSetter = this.defineWrapSetter.bind(this)
          Severity: Major
          Found in src/interceptors/decorator.ts - About 2 hrs to fix

            Function container has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            export const container = (_container: IInternalContainer) => {
                const result: IContainer = {
                    get cache(): ICache {
                        return _container.cache
                    },
            Severity: Minor
            Found in src/build/container.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 defineNonWrapStrategies has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private defineNonWrapStrategies(): IStrategy {
                    const result = <IStrategy>{}
            
                    result[propertyType.method] = (strategyInfo: IStrategyInfo) => {
            
            Severity: Minor
            Found in src/interceptors/decorator.ts - About 1 hr to fix

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

                  private instantiateByDependencies(type: {}, dependencies: {}[]) {
                      const params = dependencies
                      .map((dependency, index) => {
              
                          const depParams =
              Severity: Minor
              Found in src/build/invoker.ts - About 1 hr to fix

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

                    private internalContainerService(): IInternalContainerService {
                
                        const dependencies = () => {
                            const registrationStorageService = this.registrationStorageService()
                            const disposableStorageService = this.disposableStorageService()
                Severity: Minor
                Found in src/scaffold/index.ts - About 1 hr to fix

                  Function createRegister has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function createRegister<R>(builder: IContainerBuilder, isSelf = false) {
                      return (api: IDecoratorRegistrationApi<R>): ClassDecorator => (target) => {
                  
                          if (!isPrototype(target)) {
                              throw new DecoratorError(
                  Severity: Minor
                  Found in src/decorators/decorator.ts - About 1 hr to fix

                    Function params has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            .map((dependency, index) => {
                    
                                const depParams =
                                    this._resolutionDetails ? this._resolutionDetails.tryGet(type) : null
                                const depParamsValue = depParams ? depParams[index] : null
                    Severity: Minor
                    Found in src/build/invoker.ts - About 1 hr to fix

                      Function createDependenciesRegistration has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private createDependenciesRegistration<R>(api: IContainerApi<R>): IRegistrationBase[] {
                      
                              const items = api.dependenciesValue.map(dependency => {
                      
                                  if (!dependency.service) {
                      Severity: Minor
                      Found in src/build/internal-container.ts - About 1 hr to fix

                        Function getSubstitutes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            getSubstitutes(name: string, types: CallInfoType[]): ISubstitute | null {
                        
                                const unknown = this._unknown.head ?
                                    this.copyList(
                                        this._unknown,
                        Severity: Minor
                        Found in src/interceptors/substitute-storage.ts - 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 instantiateByParams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private instantiateByParams(
                                type: {}, registration: IRegistrationBase, throwIfNotFound: boolean) {
                        
                                const params = registration.params
                                .map(item => {
                        Severity: Minor
                        Found in src/build/invoker.ts - 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

                        Consider simplifying this complex logical expression.
                        Open

                            if ((dependency.factory && dependency.factoryType) ||
                                (dependency.factory && factoryValueKey in dependency) ||
                                (dependency.factoryType && factoryValueKey in dependency)) {
                                throw new ApplicationError({ message: 'Unknown registration type' })
                            }
                        Severity: Major
                        Found in src/utils/common.ts - About 40 mins to fix

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

                          export const getPropertyType = (descriptor?: PropertyDescriptor): PropertyType => {
                          
                              if (!descriptor) {
                                  return propertyType.field
                              }
                          Severity: Minor
                          Found in src/interceptors/common.ts - 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 createTrackable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private createTrackable(
                                  registration: IRegistrationBase, throwIfNotFound : boolean, args?: {}[]): {} {
                          
                                  try {
                                      let instance = this._invoker.invoke(registration, throwIfNotFound, args) as {}
                          Severity: Minor
                          Found in src/build/internal-container.ts - 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

                          Avoid too many return statements within this function.
                          Open

                              if (descriptor.get && descriptor.set) return propertyType.fullProperty
                          Severity: Major
                          Found in src/interceptors/common.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return propertyType.field
                            Severity: Major
                            Found in src/interceptors/common.ts - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language