Class: Evilution::Equivalent::Heuristic::CommentMarking Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/equivalent/heuristic/comment_marking.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

MARKER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/#\s*evilution:equivalent\b/

Instance Method Summary collapse

Instance Method Details

#match?(mutation) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/evilution/equivalent/heuristic/comment_marking.rb', line 8

def match?(mutation)
  source = mutation.original_source
  return false unless source

  lines = source.lines
  line_index = mutation.line - 1
  return false if line_index.negative? || line_index >= lines.length

  return true if lines[line_index].match?(MARKER)
  return true if line_index.positive? && lines[line_index - 1].match?(MARKER)

  false
end