Module: RuboCop::Cop::UncommunicativeName

Included in:
Naming::UncommunicativeBlockParamName, Naming::UncommunicativeMethodParamName
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.'.freeze
NUM_MSG =
'Do not end %<name_type>s with a number.'.freeze
LENGTH_MSG =
'%<name_type>s must be at least %<min>s ' \
'characters long.'.freeze
FORBIDDEN_MSG =
'Do not use %<name>s as a name for a ' \
'%<name_type>s.'.freeze

Instance Method Summary collapse

Instance Method Details

#check(node, args) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/rubocop/cop/mixin/uncommunicative_name.rb', line 14

def check(node, args)
  args.each do |arg|
    name = arg.children.first.to_s
    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