Class: ImproveYourCode::SmellDetectors::TooManyConstants
- Inherits:
-
BaseDetector
- Object
- BaseDetector
- ImproveYourCode::SmellDetectors::TooManyConstants
show all
- Defined in:
- lib/improve_your_code/smell_detectors/too_many_constants.rb
Constant Summary
collapse
- MAX_ALLOWED_CONSTANTS_KEY =
'max_constants'
- DEFAULT_MAX_CONSTANTS =
3
- IGNORED_NODES =
%i[module class].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
12
13
14
|
# File 'lib/improve_your_code/smell_detectors/too_many_constants.rb', line 12
def self.contexts
%i[class module]
end
|
Instance Method Details
#sniff ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/improve_your_code/smell_detectors/too_many_constants.rb', line 23
def sniff
count = constants_count
return [] if count <= max_allowed_constants
build_smell_warning(count)
end
|