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

Function validateMaxLineLength

lint/rule/rule.go:85–106  ·  view source on GitHub ↗
(typ string, expectedLen int, toCheck string)

Source from the content-addressed store, hash-verified

83}
84
85func validateMaxLineLength(typ string, expectedLen int, toCheck string) (*lint.Issue, bool) {
86 if expectedLen < 0 || toCheck == "" {
87 return nil, true
88 }
89
90 var msgs []string
91 index := 0
92 commit.ForEachLine(toCheck, func(line string) bool {
93 index++
94 if actualLen := len(line); actualLen > expectedLen {
95 msgs = append(msgs, fmt.Sprintf("in line %d, length is %d", index, actualLen))
96 }
97 return true
98 })
99
100 if len(msgs) == 0 {
101 return nil, true
102 }
103
104 desc := formMaxLineLenDesc(typ, expectedLen)
105 return lint.NewIssue(desc, msgs...), false
106}
107
108func setBoolArg(retVal *bool, arg interface{}) error {
109 boolVal, err := toBool(arg)

Callers 2

ValidateMethod · 0.85
ValidateMethod · 0.85

Calls 3

ForEachLineFunction · 0.92
NewIssueFunction · 0.92
formMaxLineLenDescFunction · 0.85

Tested by

no test coverage detected