module RuboCop::Cop::AllowedPattern
def allowed_line?(line)
def allowed_line?(line) line = if line.respond_to?(:source_line) line.source_line elsif line.respond_to?(:node) line.node.source_range.source_line end matches_allowed_pattern?(line) end
def allowed_patterns
def allowed_patterns # Since there could be a pattern specified in the default config, merge the two # arrays together. if cop_config_deprecated_methods_values.any?(Regexp) cop_config_patterns_values + cop_config_deprecated_methods_values else cop_config_patterns_values end end
def cop_config_deprecated_methods_values
def cop_config_deprecated_methods_values @cop_config_deprecated_methods_values ||= Array(cop_config.fetch('IgnoredMethods', [])) + Array(cop_config.fetch('ExcludedMethods', [])) end
def cop_config_patterns_values
def cop_config_patterns_values @cop_config_patterns_values ||= Array(cop_config.fetch('AllowedPatterns', [])) + Array(cop_config.fetch('IgnoredPatterns', [])) end
def matches_allowed_pattern?(line)
def matches_allowed_pattern?(line) allowed_patterns.any? { |pattern| Regexp.new(pattern).match?(line) } end