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

Add Cop for Superclass ActionPolicy to ApplicationPolicy #803

Closed
hoshy opened this issue Oct 7, 2022 · 2 comments
Closed

Add Cop for Superclass ActionPolicy to ApplicationPolicy #803

hoshy opened this issue Oct 7, 2022 · 2 comments

Comments

@hoshy
Copy link

hoshy commented Oct 7, 2022

Problem

When using the action_policy you should create an ApplicationPolicy class and inherit your resource policies from it (like you do with the ResourceController and ApplicationController in Rails).

It would be great, if Rubocop could check and auto-correct, that policies subclass ApplicationPolicy.

Solution

Implement a cop thats checks, that policies subclass ApplicationPolicy and may auto-correct findings – similar to the Rails/ApplicationController-Cop.

Additional context

I'm currently working on an implementation and will create a PR asap - stay tuned ;-).

hoshy added a commit to hoshy/rubocop-rails that referenced this issue Oct 7, 2022
When using the active_policy gem you should create an ApplicationPolicy class and inherit your resource policies from it.
@koic
Copy link
Member

koic commented Oct 7, 2022

Hm, RuboCop Rails basically targets Rails core features. So, I'm close this proposal because Active Policy is not a Rails core features. As an alternative, it's probably better to make a custom cop to Action Policy (or 3rd party gem) instead of RuboCop Rails. Thank you.

@koic koic closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2022
hoshy added a commit to hoshy/rubocop-rails that referenced this issue Oct 7, 2022
When using the active_policy gem you should create an ApplicationPolicy class and inherit your resource policies from it.
@hoshy
Copy link
Author

hoshy commented Oct 11, 2022

You'll find the gem here https://github.com/Nordplaner/rubocop-action_policy

@hoshy hoshy changed the title Add Cop for Superclass ActivePolicy to ApplicationPolicy Add Cop for Superclass ActionPolicy to ApplicationPolicy Oct 12, 2022
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

No branches or pull requests

2 participants