-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDangerfile.swift
More file actions
27 lines (22 loc) · 897 Bytes
/
Dangerfile.swift
File metadata and controls
27 lines (22 loc) · 897 Bytes
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
import Danger
import Foundation
let danger = Danger()
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
if editedFiles.count - danger.git.deletedFiles.count > 300 {
warn("Big PR, try to keep changes smaller if you can")
}
// Encourage writing up some reasoning about the PR, rather than just leaving a title.
let body = danger.github.pullRequest.body?.count ?? 0
let linesOfCode = danger.github.pullRequest.additions ?? 0
if body < 3 && linesOfCode > 10 {
warn("Please provide a summary in the Pull Request description")
}
// Support running via `danger local`
if danger.github != nil {
// These checks only happen on a PR
if danger.github.pullRequest.title.contains("WIP") {
warn("PR is classed as Work in Progress")
}
}
print("Running Swiftlint on changed files...")
SwiftLint.lint(.files(editedFiles), inline: true, strict: true, quiet: false)