Skip to content

Conversation

@iammukeshm
Copy link
Member

Summary

Extracted helper methods to reduce cyclomatic complexity in methods with CC 10-15.

Complexity Reduction Results

Method Before After
AddHeroRateLimiting 15 3
GetQuery<T> (SpecificationEvaluator) 13 1
ExecuteAsync (AuditBackgroundWorker) 13 5
SendAsync (SendGridMailService) 12 1
PublishSingleAsync (InMemoryEventBus) 11 3
PublishAsync (ChannelAuditPublisher) 11 2
Handle (GetAuditSummaryQueryHandler) 11 1
Handle (GetExceptionAuditsQueryHandler) 11 1
Handle (UpdateGroupCommandHandler) 11 1
UpdatePermissionsAsync (RoleService) 11 2
StartAsync (TenantAutoProvisioningHostedService) 11 3
ApplySortingOverride (Specification) 11 3

Refactoring Patterns Used

  • Extract Method: Split large methods into smaller focused helpers
  • Single Responsibility: Each helper does one thing well
  • Reduced Nesting: Flattened control flow structures

Verification

  • Build passes with 0 errors and 0 warnings
  • All refactored methods now have complexity under 10
  • No functional changes - behavior preserved

Extracted helper methods to reduce complexity in methods with CC 10-15:

Method                                          | Before | After
------------------------------------------------|--------|------
AddHeroRateLimiting                             |   15   |   3
GetQuery<T> (SpecificationEvaluator)            |   13   |   1
ExecuteAsync (AuditBackgroundWorker)            |   13   |   5
SendAsync (SendGridMailService)                 |   12   |   1
PublishSingleAsync (InMemoryEventBus)           |   11   |   3
PublishAsync (ChannelAuditPublisher)            |   11   |   2
Handle (GetAuditSummaryQueryHandler)            |   11   |   1
Handle (GetExceptionAuditsQueryHandler)         |   11   |   1
Handle (UpdateGroupCommandHandler)              |   11   |   1
UpdatePermissionsAsync (RoleService)            |   11   |   2
StartAsync (TenantAutoProvisioningHostedService)|   11   |   3
ApplySortingOverride (Specification<T>)         |   11   |   3

Refactoring patterns used:
- Extract Method: Split large methods into smaller focused helpers
- Single Responsibility: Each helper does one thing
- Reduced nesting: Flattened control flow structures

All changes pass build verification with 0 errors and 0 warnings.
@iammukeshm iammukeshm force-pushed the fix/complexity-reduction-batch3 branch from 62cc50d to a02dda8 Compare January 26, 2026 03:51
@iammukeshm iammukeshm merged commit eac87b3 into develop Jan 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants