Hooks/AlwaysReturnInFilter: remove redundant condition #783
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.
Given that:
$insideIfConditionalReturn
has a default value of0
;$insideIfConditionalReturn >= 0
condition will always betrue
.So this condition can be safely removed, just like the - now unused - assignments to the variable.
The original condition was introduced with the introduction of the sniff in #177. The condition was adjusted in #291, which made the logic redundant.
Looking at the sniff, I believe the intention was to only flag the "return outside condition missing" when not all control structure paths had a
return
statement, but this was never really properly checked as the only control structures taken into account areif
control structures.I believe it would be good to improve the sniff to handle more control structures (
switch
,while
etc) and to not throw the "return outside condition missing" error if all possible paths have areturn
statement, but that is outside the scope of the current PR.I will add a note to this effect to the review ticket for this sniff - #520.