Refactor Salesforce services and workers to simplify parameter list
Problem
There are a handful of Salesforce related workers and services that accept too many parameters for initialization. These methods accept between 9 and 11 parameters which is a big indication of complexity and a code smell. Each of the following occurrences is an exception of the Metrics/ParameterLists
cop:
Salesforce::CreateOpportunityObjectsService
Salesforce::CreateQuoteObjectsService
Salesforce::CreateAccountWorker
Salesforce::CreateOpportunityWorker
Proposal
Let's consider if there are any ways to refactor this service to reduce the amount of parameters for these methods and avoid these rubocop offenses. Ideally the maximum number of parameters would be 3.
The specific offense is actually the MaxOptionalParameters
option, which is between 5-7 for some of these methods. Can this number be reduced to the default of 3 somehow? Are all the defaults necessary/used?
Edited by Tyler Amos