Module: RuboCop::Cop::UncommunicativeName
- Included in:
- Naming::BlockParameterName, Naming::MethodParameterName
- Defined in:
- lib/rubocop/cop/mixin/uncommunicative_name.rb
Overview
Common functionality shared by Uncommunicative cops
Constant Summary collapse
- CASE_MSG =
'Only use lowercase characters for %<name_type>s.'
- NUM_MSG =
'Do not end %<name_type>s with a number.'
- LENGTH_MSG =
'%<name_type>s must be at least %<min>s ' \ 'characters long.'
- FORBIDDEN_MSG =
'Do not use %<name>s as a name for a ' \ '%<name_type>s.'
Instance Method Summary collapse
Instance Method Details
#check(node, args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubocop/cop/mixin/uncommunicative_name.rb', line 14 def check(node, args) args.each do |arg| # Argument names might be "_" or prefixed with "_" to indicate they # are unused. Trim away this prefix and only analyse the basename. full_name = arg.children.first.to_s next if full_name == '_' name = full_name.gsub(/\A([_]+)/, '') next if (arg.restarg_type? || arg.kwrestarg_type?) && name.empty? next if allowed_names.include?(name) range = arg_range(arg, name.size) issue_offenses(node, range, name) end end |