Skip to content

Instantly share code, notes, and snippets.

@coryodaniel
Created September 6, 2016 16:11
Show Gist options
  • Select an option

  • Save coryodaniel/ac838aa61a7a9ecba61e973862d8af78 to your computer and use it in GitHub Desktop.

Select an option

Save coryodaniel/ac838aa61a7a9ecba61e973862d8af78 to your computer and use it in GitHub Desktop.
CI Flog Take 2
namespace :ci do
desc "Flog it"
task :flog do
max_score = 10.0
changed_files = `git diff develop --name-only | grep "app/" | grep ".rb" | tr '\n' ' '`.split(' ')
if changed_files.any?
lines = `flog #{changed_files.join(' ')}`
failures = lines.split("\n").
drop(3).
map{ |line| line.strip.split(": ") }.
select{ |(score,info)| score.to_f >= max_score }
if failures.any?
puts "Code has exceeded max flog (#{max_score}). Clean up some code!"
failures.each do |failure|
puts failure.join(": ")
end
exit(1)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment