Skip to content

Reduce cognitive complexity in 6 methods flagged by analyzers #29

Description

@AGiorgetti

Description

The build reports 6 Cognitive Complexity violations from analyzers:

Method Complexity Allowed File
PatchForResolutionContextTracking 20 15 DetectIncorrectUsageOfTransientDisposables.cs
PatchForDetectIncorrectUsageOfTransientDisposables 27 15 DetectIncorrectUsageOfTransientDisposables.cs
CreatePatchedDescriptor 16 15 DetectIncorrectUsageOfTransientDisposables.cs
DependsOnResolutionFunc 16 15 ServiceCollectionExtensions.KeyedService.cs
KeyedDependsOnResolutionFunc 16 15 ServiceCollectionExtensions.KeyedService.cs
CreateServiceProvider 18 15 ServiceProviderFactory.cs

Suggested Approach

  • Extract keyed vs non-keyed handling into separate helper methods in patching code
  • Extract common parameter resolution logic from DependsOnResolutionFunc/KeyedDependsOnResolutionFunc
  • Extract open-generic logging into a helper in CreateServiceProvider

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions