class Reek::SmellDetectors::TooManyStatements
A Long Method is any method that has a large number of lines.
TooManyStatements
reports any method with more than 5 statements.
See {file:docs/Too-Many-Statements.md} for details.
Constants
- DEFAULT_MAX_STATEMENTS
- MAX_ALLOWED_STATEMENTS_KEY
-
The name of the config field that sets the maximum number of statements permitted in any method.
Public Class Methods
Source
# File lib/reek/smell_detectors/too_many_statements.rb, line 19 def self.default_config super.merge( MAX_ALLOWED_STATEMENTS_KEY => DEFAULT_MAX_STATEMENTS, EXCLUDE_KEY => ['initialize']) end
Calls superclass method
Reek::SmellDetectors::BaseDetector::default_config
Public Instance Methods
Source
# File lib/reek/smell_detectors/too_many_statements.rb, line 30 def sniff count = context.number_of_statements return [] if count <= max_allowed_statements [smell_warning( lines: [source_line], message: "has approx #{count} statements", parameters: { count: count })] end
Checks the length of the given method
.
@return [Array<SmellWarning>]
Private Instance Methods
Source
# File lib/reek/smell_detectors/too_many_statements.rb, line 42 def max_allowed_statements value(MAX_ALLOWED_STATEMENTS_KEY, context) end