Skip to content

Commit

Permalink
Update terminology in rails/validation.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanito Fatas authored and bbatsov committed Nov 12, 2018
1 parent 4910866 commit 9968b0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit 9968b0f

Please sign in to comment.