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

(maint) rubocop cleanup & pdksync #111

Merged
merged 1 commit into from
Jun 24, 2019

Conversation

tphoney
Copy link
Contributor

@tphoney tphoney commented Jun 14, 2019

No description provided.

@tphoney tphoney force-pushed the rubocop_cleanup branch 9 times, most recently from a55f671 to 4c6860a Compare June 17, 2019 11:29
@tphoney
Copy link
Contributor Author

tphoney commented Jun 17, 2019

image
running through ad-hoc

@tphoney tphoney changed the title {WIP} (maint) rubocop cleanup (maint) rubocop cleanup Jun 17, 2019
@tphoney tphoney changed the title (maint) rubocop cleanup (maint) rubocop cleanup & pdksync Jun 17, 2019
ThoughtCrhyme
ThoughtCrhyme previously approved these changes Jun 18, 2019
spec/lib/dsc_utils.rb Show resolved Hide resolved
end

raise "Unable to validate property #{name} (type #{mof_type[:type]}) of #{embeddedinstance_name}: value #{value}" unless respond_to?(validation_method)
send(validation_method, name, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to understand why this line is equivalent to the previous if/else statement. Is the intention here that if the raise statement is fired that execution should stop and the send would not be hit? If execution is allowed to continue after the raise fires and send is not skipped, then this rearragement would not be equivalent to the prior way the code was arranged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a raise is an exception, and should be treated as such. the send line, is the last statement in the function, and the actual implicit return

Copy link
Contributor

Choose a reason for hiding this comment

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

A Rubocop disable here as well would be appreciated.

Gemfile Show resolved Hide resolved
end
return unless host['roles'].include?('master')
step 'Sync DSC resource implementations from master to agents'
on(agents, puppet('agent -t --environment production'), acceptable_exit_codes: [0, 2])
Copy link
Contributor

Choose a reason for hiding this comment

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

The intent of the code seems much clearer under the former arrangement. It took me a little while of staring at this before I was able to work out how these two sets of code were equivalent. If we revert this to the if block style will Rubocop complain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i would argue the opposite. what happens when the if statement fails, there is no clear return.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ruby's implicit returns make it difficult to tell based on either form of this code block where the return should come from. Even on this form, should the return come from line 91? There's another on call on line 83, is that one returning data also? Really, neither of them are returning anything, and the intent of this function is not to return at all, but to perform the steps like the one on 90.

And the return unless doesn't make it clearer what the return should be since it's not really returning anything but being used to halt execution. It just makes it less clear that the two lines below should always be treated as a single unit with the conditional above.

Copy link
Contributor

Choose a reason for hiding this comment

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

As requested, I would like a Rubocop disable here if possible.

@tphoney
Copy link
Contributor Author

tphoney commented Jun 20, 2019

re run with the changes
image

@tphoney
Copy link
Contributor Author

tphoney commented Jun 24, 2019

image
Suggested changes made @RandomNoun7

@RandomNoun7 RandomNoun7 merged commit 4ab41c9 into puppetlabs:master Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants