Module: RuboCop::Cop::ForbiddenPattern

Included in:
Naming::MethodName, Naming::VariableName
Defined in:
lib/rubocop/cop/mixin/forbidden_pattern.rb

Overview

This module encapsulates the ability to forbid certain patterns in a cop.

Instance Method Summary collapse

Instance Method Details

#forbidden_pattern?(name) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/rubocop/cop/mixin/forbidden_pattern.rb', line 7

def forbidden_pattern?(name)
  forbidden_patterns.any? { |pattern| Regexp.new(pattern).match?(name) }
end

#forbidden_patternsObject



11
12
13
# File 'lib/rubocop/cop/mixin/forbidden_pattern.rb', line 11

def forbidden_patterns
  cop_config.fetch('ForbiddenPatterns', [])
end