Reduce complexity

This change reduces complexity in the code to improve CodeClimate
metrics.

[#62915462]
Merge 62915462-code-climate to master

[Completes #62915462]