class Simplabs::Excellent::Checks::Base
This is the base class for all code checks. All checks must specify interesting_contexts
. When one of these contexts is processed by Excellent
, it will invoke the evaluate_context
method of all checks that specify the context as one if their interesting_contexts
.
Attributes
An array of contexts that are interesting for the check. These contexts are based on symbols as returned by RubyParser (see parsetree.rubyforge.org/ruby_parser/) and add some additional data, e.g. Ifcontext
or MethodContext
An array of regular expressions for file names that are interesting for the check. These will usually be path extensions rather than longer patterns (e.g. *.rb as well as *.erb files or *.rb files only).
Defaults to /.rb$/. If you do not specify anything else in custom checks, only *.rb files will be processed
Public Instance Methods
Adds a warning
Parameters¶ ↑
-
context
- The context the check has been executed on. -
message
- The warning message. -
info
- The information hash that contains more info on the finding. -
offset
- The line offset that is added to the context’s line property.
# File lib/simplabs/excellent/checks/base.rb, line 53 def add_warning(context, message, info = {}, offset = 0) @warnings << Simplabs::Excellent::Warning.new(message, context.file, context.line + offset, info) end
This method is called whenever Excellent
processes a context that the check specified as one of the contexts it is interested in (see interesting_contexts
).
Parameters¶ ↑
-
context
- This is the last context the code processor has constructed. It contains all information required to execute the check (seeSimplabs::Excellent::Parsing::SexpContext
).
# File lib/simplabs/excellent/checks/base.rb, line 41 def evaluate_context(context) evaluate(context) end