[REF] simplify CRM_Activity_BAO_Activity function by using early returns #13371
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Minor code simplification - this is simpler than it looks in github - it removes 2 if blocks that can be avoided by an early return - and makes the function more legible
Before
function less legible
After
function more legible
Technical Details
This function returns a bool. In the process it sets the variable, however, once set to false in two places
it can never be set to true, so I am simply replacing a big if block with an early return to simplify the code.
This is a further block that can go but it is a slightly different patter & would remove 2 levels of 'if'
so it feels like an easier review if I leave that out of scope
Comments
@colemanw @seamuslee001 any chance one of you could take a look. It's actually pretty minor & covered by a handful of tests like testGetActivityByAclCannotViewAllContacts added to api_v3_ACLPermissionTest in preparation for cleanup