Created
September 6, 2016 16:11
-
-
Save coryodaniel/ac838aa61a7a9ecba61e973862d8af78 to your computer and use it in GitHub Desktop.
CI Flog Take 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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