An Uncommunicative Name is a name that doesn’t communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what’s going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
Currently UncommunicativeMethodName checks for
1-character names
names ending with a number
The name of the config field that lists the specific names that are to be treated as exceptions; these names will not be reported as uncommunicative.
The name of the config field that lists the regexps of smelly names to be reported.
Checks the given context for uncommunicative names.
@return [Array<SmellWarning>]
# File lib/reek/smells/uncommunicative_method_name.rb, line 59 def examine_context(ctx) @reject_names = value(REJECT_KEY, ctx, DEFAULT_REJECT_SET) @accept_names = value(ACCEPT_KEY, ctx, DEFAULT_ACCEPT_SET) name = ctx.name return [] if @accept_names.include?(ctx.full_name) var = name.to_s.gsub(/^[@\*\&]*/, '') return [] if @accept_names.include?(var) return [] unless @reject_names.detect {|patt| patt === var} smell = SmellWarning.new('UncommunicativeName', ctx.full_name, [ctx.exp.line], "has the name '#{name}'", @source, 'UncommunicativeMethodName', {METHOD_NAME_KEY => name.to_s}) [smell] end
Generated with the Darkfish Rdoc Generator 2.