maxgherman/TypeIOC

View on GitHub

Showing 52 of 52 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    private getForFactoryValue(registration: IRegistrationBase, storage: FactoryValueStore):
        IRegistrationBase | undefined {

        return !registration.name ? storage.factory.noName :
            storage.factory.names[registration.name]
Severity: Major
Found in src/storage/registration-storage.ts and 1 other location - About 1 hr to fix
src/storage/registration-storage.ts on lines 98..103

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        return {
            lazy: this.lazy,
            dispose: this.dispose,
            named: this.named,
            within: this.within,
Severity: Major
Found in src/registration/instance.ts and 1 other location - About 1 hr to fix
src/build/container-api.ts on lines 76..84

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 67.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        return {
            args: this.args,
            attempt: this.attempt,
            name: this.name,
            dependencies: this.dependencies,
Severity: Major
Found in src/build/container-api.ts and 1 other location - About 1 hr to fix
src/registration/instance.ts on lines 125..133

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 67.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                return {
                    named: this.named,
                    within: this.within,
                    transient: this.transient,
                    singleton: this.singleton,
        Severity: Major
        Found in src/decorators/registration-api.ts and 2 other locations - About 1 hr to fix
        src/build/container-api.ts on lines 90..97
        src/decorators/registration-api.ts on lines 109..116

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                return {
                    attempt: this.attempt,
                    name: this.name,
                    dependencies: this.dependencies,
                    cache: this.cache,
        Severity: Major
        Found in src/build/container-api.ts and 2 other locations - About 1 hr to fix
        src/decorators/registration-api.ts on lines 109..116
        src/decorators/registration-api.ts on lines 125..132

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                return {
                    named: this.named,
                    within: this.within,
                    transient: this.transient,
                    singleton: this.singleton,
        Severity: Major
        Found in src/decorators/registration-api.ts and 2 other locations - About 1 hr to fix
        src/build/container-api.ts on lines 90..97
        src/decorators/registration-api.ts on lines 125..132

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (!registration.name) {
                          storage.factory.noName = registration
                      } else {
                          storage.factory.names[registration.name] = registration
                      }
              Severity: Major
              Found in src/storage/registration-storage.ts and 1 other location - About 1 hr to fix
              src/storage/registration-storage.ts on lines 91..95

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (!registration.name) {
                          storage.factory.noName = registration
                      } else {
                          storage.factory.names[registration.name] = registration
                      }
              Severity: Major
              Found in src/storage/registration-storage.ts and 1 other location - About 1 hr to fix
              src/storage/registration-storage.ts on lines 61..65

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              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

              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              export interface FactoryTypeStore {
                  factory: {
                      noName?: IRegistrationBase,
                      names: IndexedCollection<IRegistrationBase>
                  },
              Severity: Minor
              Found in src/storage/types/registration-storage.ts and 1 other location - About 45 mins to fix
              src/storage/types/registration-storage.ts on lines 13..20

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              export interface FactoryValueStore {
                  factory: {
                      noName?: IRegistrationBase,
                      names: IndexedCollection<IRegistrationBase>
                  },
              Severity: Minor
              Found in src/storage/types/registration-storage.ts and 1 other location - About 45 mins to fix
              src/storage/types/registration-storage.ts on lines 4..11

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                      return {
                          name: this.name,
                          dependencies: this.dependencies,
                          cache: this.cache,
                          exec: this.exec,
              Severity: Major
              Found in src/build/container-api.ts and 3 other locations - About 40 mins to fix
              src/decorators/registration-api.ts on lines 141..147
              src/registration/instance.ts on lines 142..148
              src/registration/instance.ts on lines 154..160

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language