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

missing_presence_validation: ignore all columns with proper inclusion/exclusion validations #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fatkodima
Copy link
Contributor

Just noticed, that missing_presence_validation checker marks enum ..., validate: true as offences, even though these are false positives.

enum definition uses validates_inclusion_of under the hood, but the checker considers only boolean columns having proper inclusion/exclusion validations as good. I think, this should be extended to other column types.

@@ -62,7 +59,7 @@ def inclusion_validator_present?(model, column)
return true if validator_items.is_a?(Proc)

validator.is_a?(ActiveModel::Validations::InclusionValidator) &&
validator.attributes.include?(column.name.to_sym) &&
validator.attributes.map(&:to_s).include?(column.name) &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

enum converts attributes to strings, so we need now to check for both strings and symbols.

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.

1 participant