Skip to content

Commit f3d0572

Browse files
committed
Use CLI-style LM check configuration in report
I think this will be the easiest for the user to understand, and not require additional documentation beyond what is required to explain the CLI.
1 parent 0862c54 commit f3d0572

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

configuration/checkmode/checkmode.go

+11
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,14 @@ func Compliance(checkModes map[Type]bool) string {
105105

106106
panic(fmt.Errorf("Unrecognized compliance configuration"))
107107
}
108+
109+
// LibraryManager returns the string identifier for the Library Manager configuration mode.
110+
func LibraryManager(checkModes map[Type]bool) string {
111+
for key, value := range checkModes {
112+
if value && (key == LibraryManagerSubmission || key == LibraryManagerIndexed) {
113+
return key.String()
114+
}
115+
}
116+
117+
return "false"
118+
}

result/result.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ type projectReportType struct {
5656
}
5757

5858
type projectConfigurationReportType struct {
59-
Compliance string `json:"compliance"`
60-
LibraryManagerSubmit bool `json:"libraryManagerSubmit"`
61-
LibraryManagerUpdate bool `json:"libraryManagerUpdate"`
62-
Official bool `json:"official"`
59+
Compliance string `json:"compliance"`
60+
LibraryManager string `json:"libraryManager"`
61+
Official bool `json:"official"`
6362
}
6463

6564
type checkReportType struct {
@@ -121,10 +120,9 @@ func (results *Type) Record(checkedProject project.Type, checkConfiguration chec
121120
Path: checkedProject.Path,
122121
ProjectType: checkedProject.ProjectType.String(),
123122
Configuration: projectConfigurationReportType{
124-
Compliance: checkmode.Compliance(configuration.CheckModes(checkedProject.ProjectType)),
125-
LibraryManagerSubmit: configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerSubmission],
126-
LibraryManagerUpdate: configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerIndexed],
127-
Official: configuration.CheckModes(checkedProject.ProjectType)[checkmode.Official],
123+
Compliance: checkmode.Compliance(configuration.CheckModes(checkedProject.ProjectType)),
124+
LibraryManager: checkmode.LibraryManager(configuration.CheckModes(checkedProject.ProjectType)),
125+
Official: configuration.CheckModes(checkedProject.ProjectType)[checkmode.Official],
128126
},
129127
Checks: []checkReportType{},
130128
},

result/result_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ func TestRecord(t *testing.T) {
9191
assert.Equal(t, checkedProject.ProjectType.String(), projectReport.ProjectType)
9292
projectConfigurationReport := projectReport.Configuration
9393
assert.Equal(t, checkmode.Compliance(configuration.CheckModes(checkedProject.ProjectType)), projectConfigurationReport.Compliance)
94-
assert.Equal(t, configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerSubmission], projectConfigurationReport.LibraryManagerSubmit)
95-
assert.Equal(t, configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerIndexed], projectConfigurationReport.LibraryManagerUpdate)
94+
assert.Equal(t, checkmode.LibraryManager(configuration.CheckModes(checkedProject.ProjectType)), projectConfigurationReport.LibraryManager)
9695
assert.Equal(t, configuration.CheckModes(checkedProject.ProjectType)[checkmode.Official], projectConfigurationReport.Official)
9796
assert.Equal(t, 1, len(results.Projects[0].Checks), "Passing check reports should be written to report in verbose mode")
9897
checkReport := projectReport.Checks[0]

0 commit comments

Comments
 (0)