Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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.
  • Loading branch information
per1234 committed Dec 14, 2020
commit f3d0572fe44f60358a245cc113adc7dccf140de1
11 changes: 11 additions & 0 deletions configuration/checkmode/checkmode.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,14 @@ func Compliance(checkModes map[Type]bool) string {

panic(fmt.Errorf("Unrecognized compliance configuration"))
}

// LibraryManager returns the string identifier for the Library Manager configuration mode.
func LibraryManager(checkModes map[Type]bool) string {
for key, value := range checkModes {
if value && (key == LibraryManagerSubmission || key == LibraryManagerIndexed) {
return key.String()
}
}

return "false"
}
14 changes: 6 additions & 8 deletions result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ type projectReportType struct {
}

type projectConfigurationReportType struct {
Compliance string `json:"compliance"`
LibraryManagerSubmit bool `json:"libraryManagerSubmit"`
LibraryManagerUpdate bool `json:"libraryManagerUpdate"`
Official bool `json:"official"`
Compliance string `json:"compliance"`
LibraryManager string `json:"libraryManager"`
Official bool `json:"official"`
}

type checkReportType struct {
Expand Down Expand Up @@ -121,10 +120,9 @@ func (results *Type) Record(checkedProject project.Type, checkConfiguration chec
Path: checkedProject.Path,
ProjectType: checkedProject.ProjectType.String(),
Configuration: projectConfigurationReportType{
Compliance: checkmode.Compliance(configuration.CheckModes(checkedProject.ProjectType)),
LibraryManagerSubmit: configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerSubmission],
LibraryManagerUpdate: configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerIndexed],
Official: configuration.CheckModes(checkedProject.ProjectType)[checkmode.Official],
Compliance: checkmode.Compliance(configuration.CheckModes(checkedProject.ProjectType)),
LibraryManager: checkmode.LibraryManager(configuration.CheckModes(checkedProject.ProjectType)),
Official: configuration.CheckModes(checkedProject.ProjectType)[checkmode.Official],
},
Checks: []checkReportType{},
},
Expand Down
3 changes: 1 addition & 2 deletions result/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ func TestRecord(t *testing.T) {
assert.Equal(t, checkedProject.ProjectType.String(), projectReport.ProjectType)
projectConfigurationReport := projectReport.Configuration
assert.Equal(t, checkmode.Compliance(configuration.CheckModes(checkedProject.ProjectType)), projectConfigurationReport.Compliance)
assert.Equal(t, configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerSubmission], projectConfigurationReport.LibraryManagerSubmit)
assert.Equal(t, configuration.CheckModes(checkedProject.ProjectType)[checkmode.LibraryManagerIndexed], projectConfigurationReport.LibraryManagerUpdate)
assert.Equal(t, checkmode.LibraryManager(configuration.CheckModes(checkedProject.ProjectType)), projectConfigurationReport.LibraryManager)
assert.Equal(t, configuration.CheckModes(checkedProject.ProjectType)[checkmode.Official], projectConfigurationReport.Official)
assert.Equal(t, 1, len(results.Projects[0].Checks), "Passing check reports should be written to report in verbose mode")
checkReport := projectReport.Checks[0]
Expand Down