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

More Rubocop fixes and README.md badges #590

Merged
merged 9 commits into from
Sep 3, 2017

Conversation

alexjfisher
Copy link
Member

No description provided.

is_to_s is part of the puppet API.  This is a false positive.
@alexjfisher alexjfisher changed the title WIP: More Rubocop fixes More Rubocop fixes and README.md badges Sep 3, 2017
@alexjfisher
Copy link
Member Author

This should just leave the mulitple expectations violations.

@wyardley
Copy link
Contributor

wyardley commented Sep 3, 2017

Woah! Awesome!
May not be able to review until later this evening, but excited about this.

@@ -24,22 +24,30 @@ def should_vhost

def self.all_vhosts
vhosts = []
run_with_retries do
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this equal: vhosts = run_with_retries { rabbitmqctl('-q', 'list_vhosts') }.split(%r{\n}) or vhosts = vhost_list.split(%r{\n})

end.split(%r{\n}).each do |exchange|
end

exchange_list.split(%r{\n}).each do |exchange|
Copy link
Member

Choose a reason for hiding this comment

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

Similarly: exchanges = exchange_list.split(%r{\n}).reject { |exchange| exchange =~ %r{^federation:} }

end.split(%r{\n}).find do |line|
end

plugin_list.split(%r{\n}).find do |line|
Copy link
Member

Choose a reason for hiding this comment

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

plugin_list.split(%r{\n}).include? resource[:name]

end.split(%r{\n}).find do |line|
end

vhost_list.split(%r{\n}).find do |line|
Copy link
Member

Choose a reason for hiding this comment

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

Can also be .include?

@alexjfisher
Copy link
Member Author

Hopefully I've not messed anything up! The acceptance tests still all pass, but I've not done any other manual testing.

@alexjfisher
Copy link
Member Author

@ekohl Thanks for the review. It was too easy to just focus on the cop violation without taking a step back and looking at what the code actually did.

I've made the changes as a separate commit for now. If all looks good, I'll squash it into my Style/MultilineBlockChain commit.

@alexjfisher
Copy link
Member Author

@ekohl Rebased

@bastelfreak
Copy link
Member

I'm not an expert for types and providers, but this looks good to me

Copy link
Contributor

@wyardley wyardley left a comment

Choose a reason for hiding this comment

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

This is looking great to me, and I think the code will be more readable too.

@wyardley
Copy link
Contributor

wyardley commented Sep 3, 2017

@alexjfisher some failing tests now. I'll merge on green.

As far as release, do we want to ignore those multiple expectations warnings and do a modulesync? Or do we want to release first and do the modulesync later?

@bastelfreak
Copy link
Member

We should do a modulesync first. This is our general workflow. Also releasing without modulesync is quite painful.

@alexjfisher
Copy link
Member Author

@wyardley It looks like the tests should probably be updated. exists? should always really have been returning true or false not a string or nil.

Whilst fixing the violation, some of the code is refactored.
In particular, in some cases, exists? now returns an actual boolean
instead of a string or nil.  The tests for these providers are updated
to match the new (more correct) behaviour.
We don't support puppet 3 anymore, so most of the code can just go.
False positive.  `set_user_tags` is a rabbitmqctl subcommand.
@alexjfisher
Copy link
Member Author

Tests updated and commit comment updated in b83e247

@ekohl Does this still look ok?

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Other than that 1 thing 👍

else
raise Puppet::Error, "Could not match line '#{resource[:name]} (true|false)' from list_users (perhaps you are running on an older version of rabbitmq that does not support admin users?)"
end
raise Puppet::Error, "Could not match line '#{resource[:name]} (true|false)' from list_users (perhaps you are running on an older version of ra bbitmq that does not support admin users?)" unless (usertags = get_user_tags)
Copy link
Member

Choose a reason for hiding this comment

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

I'd do the assignment on a separate line. It's very long already. You also introduced spaces in "rabbitmq"

(:true if usertags.include?('administrator')) || :false
else
raise Puppet::Error, "Could not match line '#{resource[:name]} (true|false)' from list_users (perhaps you are running on an older version of rabbitmq that does not support admin users?)"
if (usertags = get_user_tags)
Copy link
Member Author

Choose a reason for hiding this comment

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

@ekohl How about like this?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about:

usertags = get_user_tags
raise ... unless usertags
:true if usertags.include?('administrator') || :false

And I'd see if it could handle actual booleans.

Copy link
Contributor

Choose a reason for hiding this comment

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

Look good?

@wyardley wyardley merged commit 2ebbfc3 into voxpupuli:master Sep 3, 2017
Slm0n87 pushed a commit to Slm0n87/puppet-rabbitmq that referenced this pull request Mar 7, 2019
More Rubocop fixes and README.md badges
cegeka-jenkins pushed a commit to cegeka/puppet-rabbitmq that referenced this pull request Mar 26, 2021
More Rubocop fixes and README.md badges
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants