Class: ImproveYourCode::SmellDetectors::TooManyMethods
- Inherits:
-
BaseDetector
- Object
- BaseDetector
- ImproveYourCode::SmellDetectors::TooManyMethods
show all
- Defined in:
- lib/improve_your_code/smell_detectors/too_many_methods.rb
Constant Summary
collapse
- MAX_ALLOWED_METHODS_KEY =
'max_methods'
- DEFAULT_MAX_METHODS =
5
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
11
12
13
|
# File 'lib/improve_your_code/smell_detectors/too_many_methods.rb', line 11
def self.contexts
[:class]
end
|
Instance Method Details
#sniff ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/improve_your_code/smell_detectors/too_many_methods.rb', line 22
def sniff
count = context.node_instance_methods.length
return [] if count <= max_allowed_methods
message = "Your class has #{count} methods. "\
'We propose to use ExtractClass Pattern'
[
smell_warning(
context: context,
lines: [source_line],
message: message,
parameters: { count: count }
)
]
end
|