MCPcopy Create free account
hub / github.com/conventionalcommit/commitlint / Apply

Method Apply

lint/rule/scope_enum.go:23–40  ·  view source on GitHub ↗

Apply sets the needed argument for the rule

(setting lint.RuleSetting)

Source from the content-addressed store, hash-verified

21
22// Apply sets the needed argument for the rule
23func (r *ScopeEnumRule) Apply(setting lint.RuleSetting) error {
24 err := setStringArrArg(&r.Scopes, setting.Argument)
25 if err != nil {
26 return errInvalidArg(r.Name(), err)
27 }
28
29 allowEmpty, ok := setting.Flags["allow-empty"]
30 if ok {
31 err := setBoolArg(&r.AllowEmpty, allowEmpty)
32 if err != nil {
33 return errInvalidFlag(r.Name(), "allow-empty", err)
34 }
35 }
36
37 // sorting the string elements for binary search
38 sort.Strings(r.Scopes)
39 return nil
40}
41
42// Validate validates ScopeEnumRule
43func (r *ScopeEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool) {

Callers 4

TestScopeEnum_ValidFunction · 0.95
TestScopeEnum_InvalidFunction · 0.95

Calls 5

NameMethod · 0.95
setStringArrArgFunction · 0.85
errInvalidArgFunction · 0.85
setBoolArgFunction · 0.85
errInvalidFlagFunction · 0.85

Tested by 4

TestScopeEnum_ValidFunction · 0.76
TestScopeEnum_InvalidFunction · 0.76