Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Rutkowski <[email protected]>
  • Loading branch information
mrutkows committed Apr 30, 2024
1 parent 97f0204 commit 33fedf4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
9 changes: 4 additions & 5 deletions cmd/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,17 @@ func ListComponents(writer io.Writer, persistentFlags utils.PersistentCommandFla
getLogger().Infof("Outputting listing (`%s` format)...", format)
switch format {
case FORMAT_TEXT:
DisplayComponentListText(document, writer)
err = DisplayComponentListText(document, writer)
case FORMAT_CSV:
DisplayComponentListCSV(document, writer)
err = DisplayComponentListCSV(document, writer)
case FORMAT_MARKDOWN:
DisplayComponentListMarkdown(document, writer)
err = DisplayComponentListMarkdown(document, writer)
default:
// Default to Text output for anything else (set as flag default)
getLogger().Warningf("Listing not supported for `%s` format; defaulting to `%s` format...",
format, FORMAT_TEXT)
DisplayComponentListText(document, writer)
err = DisplayComponentListText(document, writer)
}

return
}

Expand Down
9 changes: 4 additions & 5 deletions cmd/license_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func ListLicenses(writer io.Writer, policyConfig *schema.LicensePolicyConfig,
// Default to JSON output for anything else
getLogger().Warningf("Listing not supported for `%s` format; defaulting to `%s` format...",
format, FORMAT_JSON)
DisplayLicenseListJson(document, writer, licenseFlags)
err = DisplayLicenseListJson(document, writer, licenseFlags)
}
return
}
Expand Down Expand Up @@ -298,6 +298,7 @@ func DisplayLicenseListText(bom *schema.BOM, writer io.Writer, flags utils.Licen
for _, licenseName := range licenseKeys {
arrLicenseInfo, _ := bom.LicenseMap.Get(licenseName)

// Format each LicenseInfo as a line and write to output
for _, iInfo := range arrLicenseInfo {
licenseInfo = iInfo.(schema.LicenseInfo)
lc := licenseInfo.LicenseChoice
Expand Down Expand Up @@ -368,6 +369,7 @@ func DisplayLicenseListCSV(bom *schema.BOM, writer io.Writer, flags utils.Licens
os.Exit(ERROR_VALIDATION)
}

// Format each LicenseInfo as a line and write to output
for _, iInfo := range arrLicenseInfo {
licenseInfo = iInfo.(schema.LicenseInfo)
line, err = prepareReportLineData(
Expand Down Expand Up @@ -415,12 +417,9 @@ func DisplayLicenseListMarkdown(bom *schema.BOM, writer io.Writer, flags utils.L
for _, licenseName := range licenseKeys {
arrLicenseInfo, _ := bom.LicenseMap.Get(licenseName)

// Format each LicenseInfo as a line and write to output
for _, iInfo := range arrLicenseInfo {
// Each row will contain every field of a CDX LicenseChoice object
line = nil
licenseInfo = iInfo.(schema.LicenseInfo)

// Format line and write to output
line, err = prepareReportLineData(
licenseInfo,
LICENSE_LIST_ROW_DATA,
Expand Down
13 changes: 6 additions & 7 deletions cmd/vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func vulnerabilityCmdImpl(cmd *cobra.Command, args []string) (err error) {
}

err = ListVulnerabilities(writer, utils.GlobalFlags.PersistentFlags, utils.GlobalFlags.VulnerabilityFlags, whereFilters)

return
}

Expand Down Expand Up @@ -218,20 +217,19 @@ func ListVulnerabilities(writer io.Writer, persistentFlags utils.PersistentComma
getLogger().Infof("Outputting listing (`%s` format)...", format)
switch format {
case FORMAT_TEXT:
DisplayVulnListText(document, writer, flags)
err = DisplayVulnListText(document, writer, flags)
case FORMAT_CSV:
err = DisplayVulnListCSV(document, writer, flags)
case FORMAT_MARKDOWN:
err = DisplayVulnListMarkdown(document, writer, flags)
case FORMAT_JSON:
DisplayVulnListJson(document, writer, flags)
err = DisplayVulnListJson(document, writer, flags)
default:
// Default to Text output for anything else (set as flag default)
getLogger().Warningf("Listing not supported for `%s` format; defaulting to `%s` format...",
format, FORMAT_JSON)
DisplayVulnListText(document, writer, flags)
err = DisplayVulnListText(document, writer, flags)
}

return
}

Expand Down Expand Up @@ -413,7 +411,7 @@ func DisplayVulnListMarkdown(bom *schema.BOM, writer io.Writer, flags utils.Vuln
}

// Output filtered list of vulnerabilities as JSON
func DisplayVulnListJson(bom *schema.BOM, writer io.Writer, flags utils.VulnerabilityCommandFlags) {
func DisplayVulnListJson(bom *schema.BOM, writer io.Writer, flags utils.VulnerabilityCommandFlags) (err error) {
getLogger().Enter()
defer getLogger().Exit()

Expand All @@ -431,5 +429,6 @@ func DisplayVulnListJson(bom *schema.BOM, writer io.Writer, flags utils.Vulnerab

// Note: JSON data files MUST ends in a newline as this is a POSIX standard
// which is already accounted for by the JSON encoder.
utils.WriteAnyAsEncodedJSONInt(writer, vulnList, utils.GlobalFlags.PersistentFlags.GetOutputIndentInt())
_, err = utils.WriteAnyAsEncodedJSONInt(writer, vulnList, utils.GlobalFlags.PersistentFlags.GetOutputIndentInt())
return
}

0 comments on commit 33fedf4

Please sign in to comment.