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

Update terminology in rails/validation.rb #6467

Merged
merged 1 commit into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/rubocop/cop/rails/validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class Validation < Cop
uniqueness
].freeze

BLACKLIST = TYPES.map { |p| "validates_#{p}_of".to_sym }.freeze
WHITELIST = TYPES.map { |p| "validates :column, #{p}: value" }.freeze
DENYLIST = TYPES.map { |p| "validates_#{p}_of".to_sym }.freeze
ALLOWLIST = TYPES.map { |p| "validates :column, #{p}: value" }.freeze

def on_send(node)
return unless !node.receiver && BLACKLIST.include?(node.method_name)
return unless !node.receiver && DENYLIST.include?(node.method_name)

add_offense(node, location: :selector)
end
Expand All @@ -71,7 +71,7 @@ def message(node)
end

def preferred_method(method)
WHITELIST[BLACKLIST.index(method.to_sym)]
ALLOWLIST[DENYLIST.index(method.to_sym)]
end

def correct_validate_type(corrector, node)
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/rails/validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe RuboCop::Cop::Rails::Validation do
subject(:cop) { described_class.new }

described_class::BLACKLIST.each_with_index do |validation, number|
described_class::DENYLIST.each_with_index do |validation, number|
it "registers an offense for #{validation}" do
inspect_source("#{validation} :name")
expect(cop.offenses.size).to eq(1)
Expand All @@ -12,7 +12,7 @@
it "outputs the correct message for #{validation}" do
inspect_source("#{validation} :name")
expect(cop.offenses.first.message)
.to include(described_class::WHITELIST[number])
.to include(described_class::ALLOWLIST[number])
end
end

Expand Down