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

Method Format

lint/formatter/json.go:18–29  ·  view source on GitHub ↗

Format formats the lint.Result

(result *lint.Result)

Source from the content-addressed store, hash-verified

16
17// Format formats the lint.Result
18func (f *JSONFormatter) Format(result *lint.Result) (string, error) {
19 output := make(map[string]interface{}, 4)
20
21 output["input"] = result.Input()
22 output["issues"] = f.formatIssue(result.Issues())
23
24 formatted, err := json.Marshal(output)
25 if err != nil {
26 return "", fmt.Errorf("json formatting failed: %w", err)
27 }
28 return strings.Trim(string(formatted), "\n"), nil
29}
30
31func (f *JSONFormatter) formatIssue(issues []*lint.Issue) []interface{} {
32 formattedIssues := make([]interface{}, 0, len(issues))

Callers 3

Calls 3

formatIssueMethod · 0.95
InputMethod · 0.80
IssuesMethod · 0.80

Tested by 3