MCPcopy Index your code
hub / github.com/conventionalcommit/commitlint / IsSentenceCase

Function IsSentenceCase

internal/casing/casing.go:110–124  ·  view source on GitHub ↗

IsSentenceCase reports whether s is in Sentence case format. Sentence case: first rune is uppercase; every subsequent letter is lowercase. Digits and punctuation are allowed anywhere. Examples: "My feature", "Add endpoint", "Fix #123".

(s string)

Source from the content-addressed store, hash-verified

108// Digits and punctuation are allowed anywhere.
109// Examples: "My feature", "Add endpoint", "Fix #123".
110func IsSentenceCase(s string) bool {
111 if s == "" {
112 return true
113 }
114 runes := []rune(s)
115 if !unicode.IsUpper(runes[0]) {
116 return false
117 }
118 for _, r := range runes[1:] {
119 if unicode.IsLetter(r) && unicode.IsUpper(r) {
120 return false
121 }
122 }
123 return true
124}
125
126// IsSnakeCase reports whether s is in snake_case format.
127// snake_case: only lowercase letters, digits, and underscores.

Callers 2

TestIsSentenceCaseFunction · 0.92
CheckFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsSentenceCaseFunction · 0.74