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

A Rails 7.1+ cop to suggest using normalizes #1305

Open
Darhazer opened this issue Jul 1, 2024 · 2 comments
Open

A Rails 7.1+ cop to suggest using normalizes #1305

Darhazer opened this issue Jul 1, 2024 · 2 comments

Comments

@Darhazer
Copy link
Member

Darhazer commented Jul 1, 2024

Is your feature request related to a problem? Please describe.

Rails 7.1 added normalizes that can replace before_validation callbacks that change an attribute
It would be nice if we can have a cop to help people upgrade their codebases

@Earlopain
Copy link
Contributor

Earlopain commented Jul 1, 2024

Can you provide some examples you have in mind? In a codebase I worked on we had plenty of before_validations that just initialized some field, without a specific guard like on: :create.

Not the greatest pattern. Basically some immutable model once created which means before_validations run only once while with normalizes that would also run for queries against it

@fatkodima
Copy link
Contributor

Personally, I don't think this can be solved by a cop, except some of the simplest cases.

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

3 participants