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

Method Validate

rule/leading_blank_rules.go:24–42  ·  view source on GitHub ↗
(msg lint.Commit)

Source from the content-addressed store, hash-verified

22func (r *BodyLeadingBlankRule) Name() string { return "body-leading-blank" }
23func (r *BodyLeadingBlankRule) Apply(_ lint.RuleSetting) error { return nil }
24func (r *BodyLeadingBlankRule) Validate(msg lint.Commit) (*lint.Issue, bool) {
25 body := msg.Body()
26 if body == "" {
27 return nil, true
28 }
29 // The full message should have "\n\n" separating header from body.
30 raw := msg.Message()
31 headerEnd := strings.Index(raw, "\n")
32 if headerEnd == -1 {
33 // No newline at all, body is non-empty but raw message has no newline;
34 // treat as no leading blank.
35 return lint.NewIssue("body must have a leading blank line"), false
36 }
37 rest := raw[headerEnd:]
38 if strings.HasPrefix(rest, "\n\n") {
39 return nil, true
40 }
41 return lint.NewIssue("body must have a leading blank line"), false
42}
43
44// FooterLeadingBlankRule checks that when a footer is present, it begins with a blank line
45// (i.e. there is an empty line between body/header and footer).

Calls 3

NewIssueFunction · 0.92
BodyMethod · 0.65
MessageMethod · 0.65