Repository: Moya/Moya
File: Dangerfile.swift (Swift)

Code before:
import Danger
import DangerSwiftProse // package: https://github.com/f-meloni/danger-swift-prose.git
import DangerXCodeSummary // package: https://github.com/f-meloni/danger-swift-xcodesummary.git
import Foundation

let danger = Danger()

let github = danger.github

// Changelog entries are required for changes to library files.
let allSourceFiles = danger.git.modifiedFiles + danger.git.createdFiles
let changelogChanged = allSourceFiles.contains("CHANGELOG.md")
let sourceChanges = allSourceFiles.first(where: { $0.hasPrefix("Sources") }) != nil
let isTrivial = danger.github.pullRequest.title.contains("#trivial")
if !isTrivial && !changelogChanged && sourceChanges {
    danger.warn("""
         Any changes to library code should be reflected in the Changelog.
         Please consider adding a note there and adhere to the [Changelog Guidelines](https://github.com/Moya/contributors/blob/master/Changelog%20Guidelines.md).
        """)
}

// Make it more obvious that a PR is a work in progress and shouldn't be merged yet
if danger.github.pullRequest.title.contains("WIP") {
    warn("PR is classed as Work in Progress")
}

// Warn, asking to update Chinese docs if only English docs are updated and vice-versa
let enDocsModified = danger.git.modifiedFiles.first { $0.contains("docs/") } != nil
let cnDocsModified = danger.git.modifiedFiles.first { $0.contains("docs_CN/") } != nil
if (enDocsModified && !cnDocsModified) || (!enDocsModified && cnDocsModified) {
    warn("Consider **also** updating the \(enDocsModified ? "English" : "Chinese") docs. For Chinese translations, request the modified file(s) to be added to the list [here](https://github.com/Moya/Moya/issues/1357) for someone else to translate, if you can't do so yourself.")
}

// Warn, asking to update Chinese README if only English README are updated and vice-versa
let enReameModified = danger.git.modifiedFiles.first { $0.contains("Readme.md") } != nil
let chReameModified = danger.git.modifiedFiles.first { $0.contains("Readme_CN.md") } != nil
if (enReameModified && !chReameModified) || (!enReameModified && chReameModified) {

Review comment (suggestion):
```suggestion
let noChangelogEntry = !allSourceFiles.contains("CHANGELOG.md")
```

Code after:
import Danger
import DangerSwiftProse // package: https://github.com/f-meloni/danger-swift-prose.git
import DangerXCodeSummary // package: https://github.com/f-meloni/danger-swift-xcodesummary.git
import Foundation

let danger = Danger()

let github = danger.github

// Changelog entries are required for changes to library files.
let allSourceFiles = danger.git.modifiedFiles + danger.git.createdFiles
let noChangelogEntry = !allSourceFiles.contains("CHANGELOG.md")
let sourceChanges = allSourceFiles.contains { $0.hasPrefix("Sources") }
let isNotTrivial = !danger.github.pullRequest.title.contains("#trivial")
if isNotTrivial && noChangelogEntry && sourceChanges {
    danger.warn("""
         Any changes to library code should be reflected in the Changelog.
         Please consider adding a note there and adhere to the [Changelog Guidelines](https://github.com/Moya/contributors/blob/master/Changelog%20Guidelines.md).
        """)
}

// Make it more obvious that a PR is a work in progress and shouldn't be merged yet
if danger.github.pullRequest.title.contains("WIP") {
    warn("PR is classed as Work in Progress")
}

// Warn, asking to update Chinese docs if only English docs are updated and vice-versa
let enDocsModified = danger.git.modifiedFiles.contains { $0.contains("docs/") }
let cnDocsModified = danger.git.modifiedFiles.contains { $0.contains("docs_CN/") }
if (enDocsModified && !cnDocsModified) || (!enDocsModified && cnDocsModified) {
    warn("Consider **also** updating the \(enDocsModified ? "English" : "Chinese") docs. For Chinese translations, request the modified file(s) to be added to the list [here](https://github.com/Moya/Moya/issues/1357) for someone else to translate, if you can't do so yourself.")
}

// Warn, asking to update Chinese README if only English README are updated and vice-versa
let enReameModified = danger.git.modifiedFiles.contains { $0.contains("Readme.md") }
let chReameModified = danger.git.modifiedFiles.contains { $0.contains("Readme_CN.md") }
if (enReameModified && !chReameModified) || (!enReameModified && chReameModified) {