@@ -18,11 +18,11 @@ import (
1818 "github.com/arduino/go-paths-helper"
1919)
2020
21- // Report is the global instance of the check results ReportType struct
22- var Report ReportType
21+ // Results is the global instance of the check results result.Type struct
22+ var Results Type
2323
24- // ReportType is the type for the check results report
25- type ReportType struct {
24+ // Type is the type for the check results data
25+ type Type struct {
2626 Configuration toolConfigurationReportType `json:"configuration"`
2727 Projects []projectReportType `json:"projects"`
2828 Summary summaryReportType `json:"summary"`
@@ -66,17 +66,17 @@ type summaryReportType struct {
6666 ErrorCount int `json:"errorCount"`
6767}
6868
69- // Initialize adds the tool configuration data to the report .
70- func (report * ReportType ) Initialize () {
71- report .Configuration = toolConfigurationReportType {
69+ // Initialize adds the tool configuration data to the results data .
70+ func (results * Type ) Initialize () {
71+ results .Configuration = toolConfigurationReportType {
7272 Paths : []* paths.Path {configuration .TargetPath ()},
7373 ProjectType : configuration .SuperprojectTypeFilter ().String (),
7474 Recursive : configuration .Recursive (),
7575 }
7676}
7777
7878// Record records the result of a check and returns a text summary for it.
79- func (report * ReportType ) Record (checkedProject project.Type , checkConfiguration checkconfigurations.Type , checkResult checkresult.Type , checkOutput string ) string {
79+ func (results * Type ) Record (checkedProject project.Type , checkConfiguration checkconfigurations.Type , checkResult checkresult.Type , checkOutput string ) string {
8080 checkMessage := message (checkConfiguration .MessageTemplate , checkOutput )
8181
8282 checkLevel , err := checklevel .CheckLevel (checkConfiguration )
@@ -105,11 +105,11 @@ func (report *ReportType) Record(checkedProject project.Type, checkConfiguration
105105 Message : checkMessage ,
106106 }
107107
108- reportExists , projectReportIndex := report .getProjectReportIndex (checkedProject .Path )
108+ reportExists , projectReportIndex := results .getProjectReportIndex (checkedProject .Path )
109109 if ! reportExists {
110110 // There is no existing report for this project.
111- report .Projects = append (
112- report .Projects ,
111+ results .Projects = append (
112+ results .Projects ,
113113 projectReportType {
114114 Path : checkedProject .Path ,
115115 ProjectType : checkedProject .ProjectType .String (),
@@ -124,23 +124,23 @@ func (report *ReportType) Record(checkedProject project.Type, checkConfiguration
124124 )
125125 } else {
126126 // There's already a report for this project, just add the checks report to it
127- report .Projects [projectReportIndex ].Checks = append (report .Projects [projectReportIndex ].Checks , checkReport )
127+ results .Projects [projectReportIndex ].Checks = append (results .Projects [projectReportIndex ].Checks , checkReport )
128128 }
129129
130130 return summaryText
131131}
132132
133- // AddProjectSummaryReport summarizes the results of all checks on the given project and adds it to the report.
134- func (report * ReportType ) AddProjectSummaryReport (checkedProject project.Type ) {
135- reportExists , projectReportIndex := report .getProjectReportIndex (checkedProject .Path )
133+ // AddProjectSummary summarizes the results of all checks on the given project and adds it to the report.
134+ func (results * Type ) AddProjectSummary (checkedProject project.Type ) {
135+ reportExists , projectReportIndex := results .getProjectReportIndex (checkedProject .Path )
136136 if ! reportExists {
137137 panic (fmt .Sprintf ("Unable to find report for %v when generating report summary" , checkedProject .Path ))
138138 }
139139
140140 pass := true
141141 warningCount := 0
142142 errorCount := 0
143- for _ , checkReport := range report .Projects [projectReportIndex ].Checks {
143+ for _ , checkReport := range results .Projects [projectReportIndex ].Checks {
144144 if checkReport .Result == checkresult .Fail .String () {
145145 if checkReport .Level == checklevel .Warning .String () {
146146 warningCount += 1
@@ -151,56 +151,56 @@ func (report *ReportType) AddProjectSummaryReport(checkedProject project.Type) {
151151 }
152152 }
153153
154- report .Projects [projectReportIndex ].Summary = summaryReportType {
154+ results .Projects [projectReportIndex ].Summary = summaryReportType {
155155 Pass : pass ,
156156 WarningCount : warningCount ,
157157 ErrorCount : errorCount ,
158158 }
159159}
160160
161161// ProjectSummaryText returns a text summary of the check results for the given project.
162- func (report ReportType ) ProjectSummaryText (checkedProject project.Type ) string {
163- reportExists , projectReportIndex := report .getProjectReportIndex (checkedProject .Path )
162+ func (results Type ) ProjectSummaryText (checkedProject project.Type ) string {
163+ reportExists , projectReportIndex := results .getProjectReportIndex (checkedProject .Path )
164164 if ! reportExists {
165165 panic (fmt .Sprintf ("Unable to find report for %v when generating report summary text" , checkedProject .Path ))
166166 }
167167
168- projectSummaryReport := report .Projects [projectReportIndex ].Summary
168+ projectSummaryReport := results .Projects [projectReportIndex ].Summary
169169 return fmt .Sprintf ("\n Finished checking project. Results:\n Warning count: %v\n Error count: %v\n Checks passed: %v\n \n " , projectSummaryReport .WarningCount , projectSummaryReport .ErrorCount , projectSummaryReport .Pass )
170170}
171171
172- // AddSummaryReport summarizes the check results for all projects and adds it to the report.
173- func (report * ReportType ) AddSummaryReport () {
172+ // AddSummary summarizes the check results for all projects and adds it to the report.
173+ func (results * Type ) AddSummary () {
174174 pass := true
175175 warningCount := 0
176176 errorCount := 0
177- for _ , projectReport := range report .Projects {
177+ for _ , projectReport := range results .Projects {
178178 if ! projectReport .Summary .Pass {
179179 pass = false
180180 }
181181 warningCount += projectReport .Summary .WarningCount
182182 errorCount += projectReport .Summary .ErrorCount
183183 }
184184
185- report .Summary = summaryReportType {
185+ results .Summary = summaryReportType {
186186 Pass : pass ,
187187 WarningCount : warningCount ,
188188 ErrorCount : errorCount ,
189189 }
190190}
191191
192192// SummaryText returns a text summary of the cumulative check results.
193- func (report ReportType ) SummaryText () string {
194- return fmt .Sprintf ("Finished checking projects. Results:\n Warning count: %v\n Error count: %v\n Checks passed: %v\n " , report .Summary .WarningCount , report .Summary .ErrorCount , report .Summary .Pass )
193+ func (results Type ) SummaryText () string {
194+ return fmt .Sprintf ("Finished checking projects. Results:\n Warning count: %v\n Error count: %v\n Checks passed: %v\n " , results .Summary .WarningCount , results .Summary .ErrorCount , results .Summary .Pass )
195195}
196196
197- // Report returns a JSON formatted report of checks on all projects.
198- func (report ReportType ) JSONReport () string {
199- return string (report .jsonReportRaw ())
197+ // JSONReport returns a JSON formatted report of checks on all projects.
198+ func (results Type ) JSONReport () string {
199+ return string (results .jsonReportRaw ())
200200}
201201
202- func (report ReportType ) jsonReportRaw () []byte {
203- reportJSON , err := json .MarshalIndent (report , "" , " " )
202+ func (results Type ) jsonReportRaw () []byte {
203+ reportJSON , err := json .MarshalIndent (results , "" , " " )
204204 if err != nil {
205205 panic (fmt .Sprintf ("Error while formatting checks report: %v" , err ))
206206 }
@@ -209,24 +209,24 @@ func (report ReportType) jsonReportRaw() []byte {
209209}
210210
211211// WriteReport writes a report for all projects to the specified file.
212- func (report ReportType ) WriteReport () {
212+ func (results Type ) WriteReport () {
213213 // Write report file
214- err := configuration .ReportFilePath ().WriteFile (report .jsonReportRaw ())
214+ err := configuration .ReportFilePath ().WriteFile (results .jsonReportRaw ())
215215 if err != nil {
216216 feedback .Errorf ("Error while writing report: %v" , err )
217217 os .Exit (1 )
218218 }
219219}
220220
221221// Passed returns whether the checks passed cumulatively.
222- func (report ReportType ) Passed () bool {
223- return report .Summary .Pass
222+ func (results Type ) Passed () bool {
223+ return results .Summary .Pass
224224}
225225
226- func (report ReportType ) getProjectReportIndex (projectPath * paths.Path ) (bool , int ) {
226+ func (results Type ) getProjectReportIndex (projectPath * paths.Path ) (bool , int ) {
227227 var index int
228228 var projectReport projectReportType
229- for index , projectReport = range report .Projects {
229+ for index , projectReport = range results .Projects {
230230 if projectReport .Path == projectPath {
231231 return true , index
232232 }
0 commit comments