Skip to content
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

Merged
merged 1 commit into from
Mar 2, 2020
Merged

Fixes #29177 - Fix Style/EachWithObject cop #748

merged 1 commit into from
Mar 2, 2020

Conversation

mmoll
Copy link
Contributor

@mmoll mmoll commented Feb 25, 2020

No description provided.

@@ -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]; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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] }

Copy link
Member

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?

Copy link
Contributor Author

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]; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]; }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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] }}

@mmoll
Copy link
Contributor Author

mmoll commented Feb 25, 2020

There's a semicolon cop...

@ekohl
Copy link
Member

ekohl commented Feb 25, 2020

I'm kind of fan of keeping these changes small and not touch a line too much.

@mmoll
Copy link
Contributor Author

mmoll commented Feb 28, 2020

Unfortunately, neither Rubocop nor Rubymine supports an auto-fix for semicolons of these one-liners. Anyway, should all be good now.

@ekohl
Copy link
Member

ekohl commented Mar 1, 2020

Leaving it open so @lzap can have another look.

Copy link
Member

@lzap lzap left a 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.

@lzap lzap merged commit f0865ef into theforeman:develop Mar 2, 2020
@mmoll mmoll deleted the rubocop_EachWithObj branch March 2, 2020 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants