Class: Henitai::MutationSkipDirectives
- Inherits:
-
Object
- Object
- Henitai::MutationSkipDirectives
- Defined in:
- lib/henitai/mutation_skip_directives.rb,
sig/henitai.rbs
Overview
Reads # henitai:disable magic comments from subject source files and
decides whether a mutant is excluded from the run.
Grammar (backward compatible — a bare directive means "all operators"):
# henitai:disable all operators, current scope
# henitai:disable -- prose same; `--` introduces prose
# henitai:disable OpA, OpB only the named operators
# henitai:disable OpA: reason reason lands in the report
# henitai:disable: reason all operators, with reason
# henitai:disable-start [ops][: reason] region begin
# henitai:disable-end region end
Scopes: trailing comment (line), standalone comment directly above a
def (method), and disable-start/disable-end pairs (region, no nesting).
Operator names must exactly match the canonical registry names
(henitai operator list); unknown names, unmatched or nested region
directives raise Henitai::ConfigurationError with file:line.
Matching mutants are reported as ignored by StaticFilter, not dropped.
Defined Under Namespace
Classes: Directive, Index, IndexBuilder
Constant Summary collapse
- DIRECTIVE =
/\A#\s*henitai:disable(?<kind>-start|-end)?(?<rest>[:\s].*)?\z/- VALID_OPERATOR_NAMES =
Operator::FULL_SET
- EMPTY_INDEX =
Index.new( trailing: {}.freeze, standalone: {}.freeze, regions: [].freeze, standalone_comment_lines: Set.new.freeze ).freeze
Instance Method Summary collapse
-
#directive_for(mutant) ⇒ Directive?
The directive excluding this mutant, if any.
-
#initialize ⇒ MutationSkipDirectives
constructor
A new instance of MutationSkipDirectives.
- #skip?(mutant) ⇒ Boolean
Constructor Details
#initialize ⇒ MutationSkipDirectives
Returns a new instance of MutationSkipDirectives.
47 48 49 |
# File 'lib/henitai/mutation_skip_directives.rb', line 47 def initialize @index_cache = {} end |
Instance Method Details
#directive_for(mutant) ⇒ Directive?
Returns the directive excluding this mutant, if any.
56 57 58 |
# File 'lib/henitai/mutation_skip_directives.rb', line 56 def directive_for(mutant) line_directive_for(mutant) || region_directive_for(mutant) || method_directive_for(mutant) end |
#skip?(mutant) ⇒ Boolean
51 52 53 |
# File 'lib/henitai/mutation_skip_directives.rb', line 51 def skip?(mutant) !directive_for(mutant).nil? end |