Fix ineffective if warnings in discarded case branches#550
Open
JSap0914 wants to merge 2 commits into
Open
Conversation
Inspect the final expression of each case branch when the case result is discarded, so an ineffective conditional is reported even when earlier branch statements have side effects. Signed-off-by: JSup <hanjisang0914@gmail.com>
Signed-off-by: JSup <hanjisang0914@gmail.com>
JSap0914
force-pushed
the
fix-542-ineffective-if-warning
branch
from
July 15, 2026 22:37
5770999 to
ac0c926
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Why
The validator only checked whether the entire case expression was idempotent. An earlier assignment made the case look productive, so an ineffective
ifat the end of the branch escaped the existing "value was produced and then forgotten" diagnostic.Fixes #542
Tests
bundle exec rspec spec/unit/pops/validator/validator_spec.rb: 359 examples, 0 failuresbundle exec rspec spec/unit/pops: 4,798 examples, 0 failures, 3 expected pending examplesbundle exec rubocop lib/puppet/pops/validation/checker4_0.rb: no offensesruby -wcon both changed Ruby files: syntax OK