Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update comment
  • Loading branch information
Emyrk committed Jun 7, 2022
commit 0e66d8a5bdc037fee96f1bbac99d1211093eed90
7 changes: 6 additions & 1 deletion scripts/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ func InTx(m dsl.Matcher) {
// error messages for the api. A proper sentence includes proper capitalization
// and ends with punctuation.
// There are ways around the linter, but this should work in the common cases.
// Example:
// Message:
func HttpAPIErrorMessage(m dsl.Matcher) {
m.Import("github.com/coder/coder/coderd/httpapi")

isNotProperError := func(v dsl.Var) bool {
return v.Type.Is("string") &&
// Either starts with a lowercase, or ends without punctuation
// Either starts with a lowercase, or ends without punctuation.
// The reason I don't check for NOT ^[A-Z].*[.!?]$ is because there
// are some exceptions. Any string starting with a formatting
// directive (%s) for example is exempt.
(m["m"].Text.Matches(`^"[a-z].*`) ||
m["m"].Text.Matches(`.*[^.!?]"$`))
}
Expand Down