We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The Rails/RedundantAllowNil gives false positives when allow_nil/allow_blank configuration are used in nested validations.
In the example below the requirements are:
The allow_blank is therefore not redundant in the nested scope, because any other configuration would break at least one of the requirements above.
Given the following code:
class User include ActiveModel::Validations attr_accessor :email validates :email, format: { with: /some email address regexp/, allow_blank: true }, presence: { allow_nil: true } end
or
class User include ActiveModel::Validations attr_accessor :email validates :email, format: { with: /some email address regexp/, allow_blank: true }, presence: true, allow_nil: true end
Rubocop should not raise errors.
Rubocop fails with the following message: "Rails/RedundantAllowNil: allow_nil is redundant when allow_blank has the same value."
0.93.1 (using Parser 2.7.2.0, rubocop-ast 0.8.0, running on ruby 2.5.8 x86_64-linux)
The text was updated successfully, but these errors were encountered:
[Fix rubocop#376] Fix redunctant_allow_nil on different helpers false…
c79003d
… offense
Successfully merging a pull request may close this issue.
The Rails/RedundantAllowNil gives false positives when allow_nil/allow_blank configuration are used in nested validations.
In the example below the requirements are:
The allow_blank is therefore not redundant in the nested scope, because any other configuration would break at least one of the requirements above.
Steps to reproduce the problem
Given the following code:
or
Expected behavior
Rubocop should not raise errors.
Actual behavior
Rubocop fails with the following message: "Rails/RedundantAllowNil: allow_nil is redundant when allow_blank has the same value."
RuboCop version
0.93.1 (using Parser 2.7.2.0, rubocop-ast 0.8.0, running on ruby 2.5.8 x86_64-linux)
The text was updated successfully, but these errors were encountered: