Class: Pronto::Credo::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/credo/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patch) ⇒ Wrapper

Returns a new instance of Wrapper.



9
10
11
# File 'lib/pronto/credo/wrapper.rb', line 9

def initialize(patch)
  @patch = patch
end

Instance Attribute Details

#patchObject (readonly)

Returns the value of attribute patch.



7
8
9
# File 'lib/pronto/credo/wrapper.rb', line 7

def patch
  @patch
end

Instance Method Details

#lintObject



13
14
15
16
17
18
19
20
# File 'lib/pronto/credo/wrapper.rb', line 13

def lint
  return [] if patch.nil?
  path = patch.delta.new_file[:path]
  stdout, stderr, _ = Open3.capture3(credo_executable(path))
  puts "WARN: pronto-credo: #{stderr}" if stderr && stderr.size > 0
  return {} if stdout.nil? || stdout == 0
  OutputParser.new(path, stdout).parse
end