Class: Pronto::Dogma::Runner
- Inherits:
-
Runner
- Object
- Runner
- Pronto::Dogma::Runner
- Defined in:
- lib/pronto/dogma.rb
Constant Summary collapse
- ELIXIR_EXTENSIONS =
%w(.ex .exs).freeze
Instance Method Summary collapse
- #affected_lines(patch) ⇒ Object
- #dogma_lines ⇒ Object
- #dogma_output_pathname ⇒ Object
- #elixir_patches ⇒ Object
- #new_message(line, dline) ⇒ Object
- #run ⇒ Object
Instance Method Details
#affected_lines(patch) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pronto/dogma.rb', line 15 def affected_lines(patch) candidate_lines = patch.lines.select { |line| line.addition? } candidate_lines.reduce([]) do |accum, line| affected_line = dogma_lines.find do |dline| patch.repo.path.join(dline.path) == patch.new_file_full_path && dline.lineno == line.new_lineno end if affected_line accum << (line, affected_line) else accum end end end |
#dogma_lines ⇒ Object
47 48 49 50 51 52 |
# File 'lib/pronto/dogma.rb', line 47 def dogma_lines @dogma_lines ||= matching_lines( dogma_output_pathname, /(?<path>.+\.[a-z]{2,3}):(?<lineno>[0-9]+):[0-9]+: [A-Z]: (?<error_msg>.+)/ ) end |
#dogma_output_pathname ⇒ Object
41 42 43 44 45 |
# File 'lib/pronto/dogma.rb', line 41 def dogma_output_pathname @dogma_output_path ||= Pathname.new( ENV["PRONTO_DOGMA_OUTPUT"] || "dogma.out" ) end |
#elixir_patches ⇒ Object
35 36 37 38 39 |
# File 'lib/pronto/dogma.rb', line 35 def elixir_patches @patches.select do |patch| ELIXIR_EXTENSIONS.member?(File.extname(patch.new_file_full_path)) end end |
#new_message(line, dline) ⇒ Object
31 32 33 |
# File 'lib/pronto/dogma.rb', line 31 def (line, dline) Pronto::Message.new(dline.path, line, :warning, dline.error) end |
#run ⇒ Object
8 9 10 11 12 13 |
# File 'lib/pronto/dogma.rb', line 8 def run return [] unless dogma_output_pathname.exist? elixir_patches .select { |patch| patch.delta.status != :deleted } .flat_map { |patch| affected_lines(patch) } end |