Sha256: c6d3690e7a46bfbe93f3993de984b6241871da694c142f86244fdeadc80fa526

Contents?: true

Size: 651 Bytes

Versions: 3

Compression:

Stored size: 651 Bytes

Contents

require 'open3'
require_relative 'output_parser'

module Pronto
  module Credo
    class Wrapper
      attr_reader :patch

      def initialize(patch)
        @patch = patch
      end

      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

      private

      def credo_executable(path)
        "mix credo --strict --format=flycheck #{path}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pronto-credo-0.0.8 lib/pronto/credo/wrapper.rb
pronto-credo-0.0.7 lib/pronto/credo/wrapper.rb
pronto-credo-0.0.6 lib/pronto/credo/wrapper.rb