-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDangerfile
More file actions
37 lines (30 loc) · 1.04 KB
/
Dangerfile
File metadata and controls
37 lines (30 loc) · 1.04 KB
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
32
33
34
35
36
37
# Dangerfile
# Simple Ruby-based Danger configuration
# Warn when there are no tests
has_app_changes = !git.modified_files.grep(/Modules/).empty?
has_test_changes = !git.modified_files.grep(/Tests/).empty?
if has_app_changes && !has_test_changes
warn("Changes to app code without tests. Please add tests.")
end
# Check PR size
if git.lines_of_code > 500
warn("This PR is quite large (#{git.lines_of_code} lines). Consider breaking it up.")
end
# Ensure PR has a description
if github.pr_body.length < 10
fail("Please provide a meaningful PR description.")
end
# Welcome new contributors
if github.pr_author == github.pr_author && git.commits.count == 1
message("Thanks for your contribution! 🎉")
end
# Check for print statements
swift_files = git.modified_files.select { |f| f.end_with?(".swift") }
swift_files.each do |file|
next unless File.exist?(file)
File.readlines(file).each_with_index do |line, index|
if line.include?("print(") && !file.include?("Test")
warn("Print statement found at #{file}:#{index + 1}")
end
end
end