fix access priorities of each level in LeveledOptions (#1118)#6
fix access priorities of each level in LeveledOptions (#1118)#6MitchLewis930 wants to merge 1 commit intopr_056_beforefrom
Conversation
📝 WalkthroughWalkthroughThis pull request reverses the lookup order in Puma's Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)test/test_config.rb (2)
🔇 Additional comments (1)
✏️ Tip: You can disable this entire section by setting Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
lib/puma/configuration.rb (2)
92-102:⚠️ Potential issue | 🟠 MajorInconsistency:
flattenstill prioritizes earlier layers.The
flattenmethod uses forward iteration with||=, which gives priority to the first occurrence of a key. This is now inconsistent with[]which usesreverse_eachto prioritize the last (most recent) occurrence.For example, if
@set = [{}, {workers: 3}, {workers: 4}]:
self[:workers]returns4(most recent)flatten[:workers]returns3(first non-nil)Proposed fix to align `flatten` with the new priority order
def flatten options = {} - `@set.each` do |o| + `@set.reverse_each` do |o| o.each do |k,v| options[k] ||= v end end options end
76-84:⚠️ Potential issue | 🔴 CriticalTypo:
@defaultshould be@defaults.Line 83 references
@defaultbut the instance variable is defined as@defaultson line 20. This would raise aNoMethodErrorwhen a key is not found in any layer of@set.Proposed fix
def key?(key) `@set.each` do |o| if o.key? key return true end end - `@default.key`? key + `@defaults.key`? key end
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lib/puma/configuration.rbtest/test_config.rb
🧰 Additional context used
🧬 Code graph analysis (1)
test/test_config.rb (3)
lib/puma/dsl.rb (3)
workers(286-288)load(7-14)load(118-120)lib/puma/configuration.rb (1)
load(190-208)lib/puma/state_file.rb (1)
load(13-15)
🔇 Additional comments (2)
lib/puma/configuration.rb (1)
33-38: LGTM! Reverse iteration correctly prioritizes recent layers.The change to
reverse_eachensures that the most recently added option layer takes precedence when looking up a key, which is the expected behavior for layered configuration overrides.test/test_config.rb (1)
60-69: Test correctly validates the override behavior.The test properly exercises the mutability of options after load, confirming that the
reverse_eachchange ensures the most recently set value takes precedence.Minor style note: The assertion argument order is
expected, actualin Test::Unit (e.g.,assert_equal 3, conf.options[:workers]), though the current order will still work.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
PR_056
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.