-
Notifications
You must be signed in to change notification settings - Fork 414
/
Dangerfile
31 lines (25 loc) · 1.19 KB
/
Dangerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true
# Warn when there is a big PR
warn('Big PR') if git.lines_of_code > 500
# Don't let testing shortcuts get into master by accident
(git.modified_files + git.added_files - %w[Dangerfile]).each do |file|
next unless File.file?(file)
contents = File.read(file)
if file.start_with?('spec')
failure("`xit` or `fit` left in tests (#{file})") if contents =~ /^\w*[xf]it/
failure("`fdescribe` left in tests (#{file})") if contents =~ /^\w*fdescribe/
end
end
# Sometimes its a README fix, or something like that - which isn't relevant for
# including in a CHANGELOG for example
has_app_changes = !git.modified_files.grep(/lib/).empty?
has_test_changes = !git.modified_files.grep(/spec/).empty?
# Add a CHANGELOG entry for app changes
if !git.modified_files.include?('CHANGELOG.md') && has_app_changes
failure "Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/realm/jazzy/blob/master/CHANGELOG.md)."
message 'Note, we hard-wrap at 80 chars and use 2 spaces after the last line.'
end
# Non-trivial amounts of app changes without tests
if git.lines_of_code > 50 && has_app_changes && !has_test_changes
warn 'This PR may need tests.'
end