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

Method Validate

rule/footer_enum.go:34–51  ·  view source on GitHub ↗

Validate validates FooterEnumRule

(msg lint.Commit)

Source from the content-addressed store, hash-verified

32
33// Validate validates FooterEnumRule
34func (r *FooterEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool) {
35 var invalids []string
36
37 for _, note := range msg.Notes() {
38 isFound := search(r.Tokens, note.Token())
39 if !isFound {
40 invalids = append(invalids, note.Token())
41 }
42 }
43
44 if len(invalids) == 0 {
45 return nil, true
46 }
47
48 desc := fmt.Sprintf("you can use one of %v", r.Tokens)
49 info := fmt.Sprintf("[%s] tokens are not allowed", strings.Join(invalids, ", "))
50 return lint.NewIssue(desc, info), false
51}

Callers 3

TestFooterEnum_ValidFunction · 0.95
TestFooterEnum_InvalidFunction · 0.95

Calls 4

NewIssueFunction · 0.92
searchFunction · 0.85
NotesMethod · 0.65
TokenMethod · 0.65

Tested by 3

TestFooterEnum_ValidFunction · 0.76
TestFooterEnum_InvalidFunction · 0.76