Class: Danger::DangerRegexp

Inherits:
Plugin
  • Object
show all
Defined in:
lib/danger_plugin.rb

Instance Method Summary collapse

Instance Method Details

#lint(&block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/danger_plugin.rb', line 5

def lint(&block)
  @map = {}

  instance_eval(&block)

  git.diff.each do |diff|
    GitDiffParser::Patch.new(diff.patch).changed_lines.each do |line|
      @map.each do |regexp, message|
        if line.content.match?(regexp)
          markdown(message, file: diff.path, line: line.number)
        end
      end
    end
  end
end