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

Rework how we autocorrect allowed actions #436

Merged
merged 2 commits into from
Dec 11, 2019
Merged

Rework how we autocorrect allowed actions #436

merged 2 commits into from
Dec 11, 2019

Conversation

tas50
Copy link
Contributor

@tas50 tas50 commented Dec 10, 2019

Don't remove them if we're not in a custom resource
Consider the custom resource cop to be ChefRedundant since there has never been a need for this code in a custom resource. It's just leftover redundant junk
Add a new cop ChefModernize/AllowedActionsFromInitialize that pulls the allowed_actions out of initialize methods in HWRPs. This gets folks closer to LWRPs which gets them closer to custom resources

Signed-off-by: Tim Smith tsmith@chef.io

MSG = 'The allowed actions of a resource can be set with the "allowed_actions" helper instead of using the initialize method.'.freeze

def on_def(node)
return unless node.method_name == :initialize
Copy link
Member

Choose a reason for hiding this comment

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

There's no reasonable case where someone might define these outside of initialize is there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If they're using them outside the intialize that's a different case and we want to avoid breaking their code. It could just be any old library setting those values and fixing that would be bad.

Don't remove them if we're not in a custom resource
Consider the custom resource cop to be ChefRedundant since there has never been a need for this code in a custom resource. It's just leftover redundant junk
Add a new cop ChefModernize/AllowedActionsFromInitialize that pulls the allowed_actions out of initialize methods in HWRPs. This gets folks closer to LWRPs which gets them closer to custom resources

Signed-off-by: Tim Smith <tsmith@chef.io>
Signed-off-by: Tim Smith <tsmith@chef.io>
@tas50 tas50 merged commit fc8491f into master Dec 11, 2019
@chef-expeditor chef-expeditor bot deleted the action_cleanup branch December 11, 2019 17:38
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.

2 participants