Class: Lintrunner::Runner::Diff
- Defined in:
- lib/lintrunner/runner/diff.rb
Instance Attribute Summary
Attributes inherited from Base
#executor, #git, #match, #path
Instance Method Summary collapse
Methods inherited from Base
Methods included from GitHelpers
#git_changeset, #git_common_ancestor
Constructor Details
This class inherits a constructor from Lintrunner::Runner::Base
Instance Method Details
#run(reporter) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lintrunner/runner/diff.rb', line 5 def run(reporter) warnings = [] git_changeset.each do |patch| filename = patch.delta.new_file[:path] next if patch.delta.binary? next if filename.end_with?('app/styles/pattern-guide/pattern-guide.scss') next unless filename =~ match before_contents = contents_for(patch.delta, :src) after_contents = contents_for(patch.delta, :dst) if before_contents && after_contents before_file = tempfile(before_contents) after_file = tempfile(after_contents) = executor.execute(before_file, filename: filename) = executor.execute(after_file, filename: filename) line_map = line_map_for(patch) .each do |lint| same_lint = .find do |b_lint| b_lint.line == line_map[lint.line] && b_lint.name == lint.name && b_lint.description == lint.description end warnings << lint unless same_lint reporter.report(lint) unless same_lint end elsif after_contents after_file = tempfile(after_contents) = executor.execute(after_file, filename: filename) warnings.concat output = .collect do || reporter.report() end end end warnings end |