Apply sets the needed argument for the rule
(setting lint.RuleSetting)
| 21 | |
| 22 | // Apply sets the needed argument for the rule |
| 23 | func (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 |
| 43 | func (r *ScopeEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool) { |