Class: ImproveYourCode::SmellDetectors::UncommunicativeVariableName
- Inherits:
-
BaseDetector
- Object
- BaseDetector
- ImproveYourCode::SmellDetectors::UncommunicativeVariableName
show all
- Defined in:
- lib/improve_your_code/smell_detectors/uncommunicative_variable_name.rb
Constant Summary
collapse
- REJECT_KEY =
'reject'
- DEFAULT_REJECT_SET =
[
/^.$/, /[0-9]$/, /[A-Z]/ ].freeze
- ACCEPT_KEY =
'accept'
- DEFAULT_ACCEPT_SET =
[/^_$/].freeze
Constants inherited
from BaseDetector
BaseDetector::EXCLUDE_KEY
Instance Attribute Summary
Attributes inherited from BaseDetector
#config
Class Method Summary
collapse
Instance Method Summary
collapse
configuration_keys, descendants, inherited, #initialize, #run, #smell_type, smell_type, to_detector, todo_configuration_for, valid_detector?
Class Method Details
.contexts ⇒ Object
24
25
26
|
# File 'lib/improve_your_code/smell_detectors/uncommunicative_variable_name.rb', line 24
def self.contexts
%i[module class def defs]
end
|
Instance Method Details
#sniff ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/improve_your_code/smell_detectors/uncommunicative_variable_name.rb', line 28
def sniff
variable_names.select do |name, _lines|
uncommunicative_variable_name?(name)
end.map do |name, lines|
smell_warning(
context: context,
lines: lines,
message: "has the variable name '#{name}'",
parameters: { name: name.to_s }
)
end
end
|