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

Method Validate

rule/scope_enum.go:43–59  ·  view source on GitHub ↗

Validate validates ScopeEnumRule

(msg lint.Commit)

Source from the content-addressed store, hash-verified

41
42// Validate validates ScopeEnumRule
43func (r *ScopeEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool) {
44 if msg.Scope() == "" {
45 if r.AllowEmpty {
46 return nil, true
47 }
48 errMsg := fmt.Sprintf("empty scope is not allowed, you can use one of %v", r.Scopes)
49 return lint.NewIssue(errMsg), false
50 }
51
52 isFound := search(r.Scopes, msg.Scope())
53 if isFound {
54 return nil, true
55 }
56
57 errMsg := fmt.Sprintf("scope '%s' is not allowed, you can use one of %v", msg.Scope(), r.Scopes)
58 return lint.NewIssue(errMsg), false
59}

Callers 4

TestScopeEnum_ValidFunction · 0.95
TestScopeEnum_InvalidFunction · 0.95

Calls 3

NewIssueFunction · 0.92
searchFunction · 0.85
ScopeMethod · 0.65

Tested by 4

TestScopeEnum_ValidFunction · 0.76
TestScopeEnum_InvalidFunction · 0.76