Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run credo in parallel #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/pronto/credo_runner.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require 'pronto'
require 'pronto/credo/wrapper'
require 'parallel'

module Pronto
class CredoRunner < Runner
ELIXIR_EXTENSIONS = %w(.ex .exs).freeze

def initialize(_, _)
super
end
Expand All @@ -12,10 +15,9 @@ def run

compile if ENV["PRONTO_CREDO_COMPILE"] == "1"

@patches.select { |p| p.additions > 0 }
patches = @patches.select { |p| p.additions > 0 }
.select { |p| elixir_file?(p.new_file_full_path) }
.map { |p| inspect(p) }
.flatten
Parallel.flat_map(patches, in_threads: Parallel.processor_count) { |p| inspect(p) }
.compact
end

Expand Down Expand Up @@ -46,7 +48,7 @@ def new_message(offence, line)
end

def elixir_file?(path)
%w(.ex .exs).include?(File.extname(path))
ELIXIR_EXTENSIONS.include?(File.extname(path))
end
end
end
1 change: 1 addition & 0 deletions pronto-credo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec', '~> 3.3'

spec.add_runtime_dependency 'pronto', '~> 0.7', '> 0.7.0'
spec.add_runtime_dependency 'parallel', '~> 1.14'
end