-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #29177 - Fix Style/EachWithObject cop #748
Conversation
modules/dhcp_common/server.rb
Outdated
@@ -185,7 +185,7 @@ def clean_up_add_record_parameters(in_options) | |||
subnet = options.delete("network") | |||
|
|||
# convert string keys to symbols | |||
options = options.inject({}){|all, current| all[current[0].to_sym] = current[1]; all} | |||
options = options.each_with_object({}){|current, all| all[current[0].to_sym] = current[1]; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options = options.each_with_object({}){|current, all| all[current[0].to_sym] = current[1]; } | |
options = options.each_with_object({}){|current, all| all[current[0].to_sym] = current[1] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, itsnt this a change? It returned all
, now it returns what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.rubocop.org/en/stable/cops_style/#styleeachwithobject describes exactly this: "...without the need to return the object at the end."
@@ -288,7 +286,7 @@ def sunw_option(option_id) | |||
end | |||
|
|||
def generate_sunw_options_by_id | |||
SUNW.inject({}) { |all, current| all[current[1][:code]] = current[0]; all } | |||
SUNW.each_with_object({}) { |current, all| all[current[1][:code]] = current[0]; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUNW.each_with_object({}) { |current, all| all[current[1][:code]] = current[0]; } | |
SUNW.each_with_object({}) { |current, all| all[current[1][:code]] = current[0] } |
@@ -40,7 +40,7 @@ def test_initialize_plugins | |||
assert all_but_uninitialized.all? {|p| p.has_key?(:di_container)} | |||
|
|||
# filter out :di_container, can't use equality test with it | |||
loaded = plugins.loaded.map {|p| [:name, :version, :class, :state, :http_enabled, :capabilities, :settings, :https_enabled].inject({}) {|a, c| a[c] = p[c]; a}} | |||
loaded = plugins.loaded.map {|p| [:name, :version, :class, :state, :http_enabled, :capabilities, :settings, :https_enabled].each_with_object({}) {|c, a| a[c] = p[c]; }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loaded = plugins.loaded.map {|p| [:name, :version, :class, :state, :http_enabled, :capabilities, :settings, :https_enabled].each_with_object({}) {|c, a| a[c] = p[c]; }} | |
loaded = plugins.loaded.map {|p| [:name, :version, :class, :state, :http_enabled, :capabilities, :settings, :https_enabled].each_with_object({}) {|c, a| a[c] = p[c] }} |
There's a semicolon cop... |
I'm kind of fan of keeping these changes small and not touch a line too much. |
Unfortunately, neither Rubocop nor Rubymine supports an auto-fix for semicolons of these one-liners. Anyway, should all be good now. |
Leaving it open so @lzap can have another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't spotted anything wrong, thanks.
No description provided.