Skip to content
Ahmed Tarek edited this page Feb 14, 2019 · 8 revisions

Welcome to the Koshry wiki!

How to write Koshry Rules?

Koshry has ready rules to apply on the git diff of your pull request:

1. Line Rule

  • Use it when you want to apply a condition to all of the added and modified lines in the pull request.
  • if the condition is met, Koshry will add a new issue to the report.
  • The added issue contains the file path and line number.
val rule = lineRule {
    condition = { file , line -> line.text.contains("android.util.Log") }
    reportTitle = "Don't use android.util.Log, use our custom Logger"
    issueLevel = WARN()
}

2. Protected File Rule

  • Protect a list of files to be changed by any pull request author.
  • Exclude some an author or more from this rule if you want.
val rule = protectedFileRule {
    reportTitle = "Files are protected and can't be modified, ask @tarek360 to modify"
    issueLevel = ERROR()
    files {
        filePath = "dependencies.kts"
        filePath = ".circleci/config.yml"
    }
    excludeAuthors {
        author = "tarek360"
    }
}
Clone this wiki locally