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

Function Check

internal/casing/casing.go:30–54  ·  view source on GitHub ↗

Check returns true when s conforms to the given caseFormat constant. An empty string always returns true (treated as "not present"). Returns false for any unrecognised caseFormat value.

(s, caseFormat string)

Source from the content-addressed store, hash-verified

28// An empty string always returns true (treated as "not present").
29// Returns false for any unrecognised caseFormat value.
30func Check(s, caseFormat string) bool {
31 if s == "" {
32 return true
33 }
34 switch caseFormat {
35 case Lower:
36 return s == strings.ToLower(s)
37 case Upper:
38 return s == strings.ToUpper(s)
39 case Camel:
40 return IsCamelCase(s)
41 case Kebab:
42 return IsKebabCase(s)
43 case Pascal:
44 return IsPascalCase(s)
45 case Sentence:
46 return IsSentenceCase(s)
47 case Snake:
48 return IsSnakeCase(s)
49 case Start:
50 return IsStartCase(s)
51 default:
52 return false
53 }
54}
55
56// IsCamelCase reports whether s is in camelCase format.
57// camelCase: starts with a lowercase letter and contains only letters and

Callers 7

ValidateMethod · 0.92
ValidateMethod · 0.92
ValidateMethod · 0.92
ValidateMethod · 0.92
ValidateMethod · 0.92
TestCheck_AllFormatsFunction · 0.92
TestCheck_UnknownFormatFunction · 0.92

Calls 6

IsCamelCaseFunction · 0.85
IsKebabCaseFunction · 0.85
IsPascalCaseFunction · 0.85
IsSentenceCaseFunction · 0.85
IsSnakeCaseFunction · 0.85
IsStartCaseFunction · 0.85

Tested by 2

TestCheck_AllFormatsFunction · 0.74
TestCheck_UnknownFormatFunction · 0.74