/
allowed_methods.rb
40 lines (34 loc) · 1.07 KB
/
allowed_methods.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true
module RuboCop
module Cop
# This module encapsulates the ability to allow certain methods when
# parsing.
module AllowedMethods
private
# @api public
def allowed_method?(name)
allowed_methods.include?(name.to_s)
end
# @deprecated Use allowed_method? instead
alias ignored_method? allowed_method?
# @api public
def allowed_methods
if cop_config_deprecated_values.any?(Regexp)
cop_config_allowed_methods
else
cop_config_allowed_methods + cop_config_deprecated_values
end
end
def cop_config_allowed_methods
@cop_config_allowed_methods ||= Array(cop_config.fetch('AllowedMethods', []))
end
def cop_config_deprecated_values
@cop_config_deprecated_values ||=
Array(cop_config.fetch('IgnoredMethods', [])) +
Array(cop_config.fetch('ExcludedMethods', []))
end
end
# @deprecated IgnoredMethods class has been replaced with AllowedMethods.
IgnoredMethods = AllowedMethods
end
end