Skip to content

Commit

Permalink
Exclude some files from danger PR size check (#3445)
Browse files Browse the repository at this point in the history
exclude some files from danger PR size check so that the danger-bot doesn't start yelling at folks for CRUD'ing large testing fixtures that generally don't add to the "size" of a PR to from a review perspective
  • Loading branch information
omgitsbillryan authored Oct 22, 2019
1 parent d518c8e commit 6b5d6bc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Warn if a pull request is too big
MAX_PR_SIZE = 250
if git.lines_of_code > MAX_PR_SIZE
EXCLUSIONS = ['Gemfile.lock', '.json', 'spec/fixtures/', '.txt', 'spec/support/vcr_cassettes/']

# takes form {"some/file.rb"=>{:insertions=>4, :deletions=>1}}
changed_files = git.diff.stats[:files]

filtered_changed_files = changed_files.reject { |key| EXCLUSIONS.any? { |exclusion| key.include?(exclusion) } }
lines_of_code = filtered_changed_files.sum { |_file, changes| (changes[:insertions] + changes[:deletions]) }

if lines_of_code > MAX_PR_SIZE
warn("PR is exceeds `#{MAX_PR_SIZE}` LoC. Consider breaking up into multiple smaller ones.")
end

Expand Down

0 comments on commit 6b5d6bc

Please sign in to comment.