Reduce complexity in Salesforce workers
Problem
A Code Climate report (attached here) has identified multiple problems with the Salesforce workers like Salesforce::CreateAccountWorker
. These workers can be quite complex with a long list of parameters that can be passed in.
-
Salesforce::CreateAccountWorker
- Method
perform
has 8 arguments (exceeds 4 allowed). - Method
perform
has a Cognitive Complexity of 12 (exceeds 5 allowed).
- Method
-
Salesforce::CreateOpportunityWorker
- Method
integration_perform
has 6 arguments (exceeds 4 allowed).
- Method
-
Salesforce::CreateQuoteForReconciliationWorker
- Method
integration_perform
has a Cognitive Complexity of 9 (exceeds 5 allowed). - Method
integration_perform
has 43 lines of code (exceeds 25 allowed).
- Method
-
Salesforce::CreateQuoteRatePlanChargeService
- Method
initialize
has 33 lines of code (exceeds 25 allowed). - Method
attributes
has 32 lines of code (exceeds 25 allowed).
- Method
-
Salesforce::CreateQuoteService
- Method
attributes
has 28 lines of code (exceeds 25 allowed).
- Method
There is a similar thread of complexity throughout these workers.
Proposal
Let's consider some solutions that can be applied across these classes to reduce complexity.