Reduce complexity in SelfService::Subscriptions services

Problem

A Code Climate report (attached here) has identified multiple problems with SelfService::Subscriptions::CreateService and SelfService::Subscriptions::UpdateService.

Click to expand

Screenshot_2024-08-27_at_3.11.02_PM

Screenshot_2024-08-27_at_3.11.31_PM

SelfService::Subscriptions::UpdateService

  • Method execute has a Cognitive Complexity of 9 (exceeds 5 allowed)
  • Method post_process has a Cognitive Complexity of 6 (exceeds 5 allowed)
  • Class UpdateService has 23 methods (exceeds 20 allowed)
  • Avoid deeply nested control flow statements in validate_update

SelfService::Subscriptions::CreateService

  • Method execute has a Cognitive Complexity of 17 (exceeds 5 allowed)

Proposal

Let's consider some solutions that can be applied to this class to reduce complexity and address some of these warnings above.

Edited Aug 27, 2024 by Tyler Amos
Assignee Loading
Time tracking Loading