class Reek::SmellDetectors::TooManyMethods
A Large Class is a class or module that has a large number of instance variables, methods or lines of code.
TooManyMethods
reports classes having more than a configurable number of methods. The method count includes public, protected and private methods, and excludes methods inherited from superclasses or included modules.
See {file:docs/Too-Many-Methods.md} for details.
Constants
- DEFAULT_MAX_METHODS
- MAX_ALLOWED_METHODS_KEY
-
The name of the config field that sets the maximum number of methods permitted in a class.
Public Class Methods
Source
# File lib/reek/smell_detectors/too_many_methods.rb, line 23 def self.contexts [:class] end
Source
# File lib/reek/smell_detectors/too_many_methods.rb, line 27 def self.default_config super.merge( MAX_ALLOWED_METHODS_KEY => DEFAULT_MAX_METHODS, EXCLUDE_KEY => []) end
Calls superclass method
Reek::SmellDetectors::BaseDetector::default_config
Public Instance Methods
Source
# File lib/reek/smell_detectors/too_many_methods.rb, line 38 def sniff # TODO: Only checks instance methods! actual = context.node_instance_methods.length return [] if actual <= max_allowed_methods [smell_warning( lines: [source_line], message: "has at least #{actual} methods", parameters: { count: actual })] end
Checks context for too many methods
@return [Array<SmellWarning>]
Private Instance Methods
Source
# File lib/reek/smell_detectors/too_many_methods.rb, line 51 def max_allowed_methods value(MAX_ALLOWED_METHODS_KEY, context) end