MCPcopy Create free account
hub / github.com/conforma/cli / toFormat

Method toFormat

internal/input/report.go:158–172  ·  view source on GitHub ↗

toFormat converts the report into the given format.

(format string)

Source from the content-addressed store, hash-verified

156
157// toFormat converts the report into the given format.
158func (r *Report) toFormat(format string) (data []byte, err error) {
159 switch format {
160 case JSON:
161 data, err = json.Marshal(r)
162 case YAML:
163 data, err = yaml.Marshal(r)
164 case Text:
165 data, err = generateTextReport(r)
166 case Summary:
167 data, err = json.Marshal(r.toSummary())
168 default:
169 return nil, fmt.Errorf("%q is not a valid report format", format)
170 }
171 return
172}
173
174// toSummary returns a condensed version of the report.
175func (r *Report) toSummary() summary {

Callers 6

Test_ReportJsonFunction · 0.95
Test_ReportYamlFunction · 0.95
Test_ReportTextFunction · 0.95
WriteAllMethod · 0.95

Calls 3

toSummaryMethod · 0.95
generateTextReportFunction · 0.70
ErrorfMethod · 0.65

Tested by 5

Test_ReportJsonFunction · 0.76
Test_ReportYamlFunction · 0.76
Test_ReportTextFunction · 0.76