Skip to content

Commit

Permalink
address linter complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
Frankie Gallina-Jones committed Mar 24, 2022
1 parent f9cc5a1 commit ca29922
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 14 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5
github.com/gabriel-vasile/mimetype v1.4.0
github.com/google/uuid v1.3.0
github.com/hashicorp/go-version v1.4.0
github.com/onsi/gomega v1.18.1
github.com/pelletier/go-toml v1.9.4
github.com/sclevine/spec v1.4.0
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,6 @@ github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4=
github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func encodeAuthor(p pkg.Package) string {
return ""
}

//nolint:unused
func decodeAuthor(author string, metadata interface{}) {
switch meta := metadata.(type) {
case *pkg.NpmPackageJSONMetadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func hasMetadata(p pkg.Package) bool {
return p.Metadata != nil
}

//nolint:unused,deadcode
func decodeComponent(c *cyclonedx.Component) *pkg.Package {
values := map[string]string{}
for _, p := range *c.Properties {
Expand All @@ -71,12 +72,14 @@ func decodeComponent(c *cyclonedx.Component) *pkg.Package {
return p
}

//nolint:unused
func decodeLocations(vals map[string]string) []source.Location {
v := common.Decode(reflect.TypeOf([]source.Location{}), vals, "syft:location", CycloneDXFields)
out, _ := v.([]source.Location)
return out
}

//nolint:unused
func decodePackageMetadata(vals map[string]string, c *cyclonedx.Component, typ pkg.MetadataType) interface{} {
if typ != "" && c.Properties != nil {
metaTyp, ok := pkg.MetadataTypeByName[typ]
Expand Down
1 change: 1 addition & 0 deletions sbom/internal/formats/cyclonedx13/cyclonedxhelpers/cpe.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func encodeCPEs(p pkg.Package) (out []cyclonedx.Property) {
return
}

//nolint:unused
func decodeCPEs(c *cyclonedx.Component) (out []pkg.CPE) {
if c.CPE != "" {
cp, err := pkg.NewCPE(c.CPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func encodeDescription(p pkg.Package) string {
return ""
}

//nolint:unused
func decodeDescription(description string, metadata interface{}) {
switch meta := metadata.(type) {
case *pkg.ApkMetadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func encodeExternalReferences(p pkg.Package) *[]cyclonedx.ExternalReference {
return nil
}

//nolint:unused
func decodeExternalReferences(c *cyclonedx.Component, metadata interface{}) {
if c.ExternalReferences == nil {
return
Expand All @@ -90,6 +91,7 @@ func decodeExternalReferences(c *cyclonedx.Component, metadata interface{}) {
}
}

//nolint:unused
func findExternalRef(c *cyclonedx.Component, typ cyclonedx.ExternalReferenceType) *cyclonedx.ExternalReference {
if c.ExternalReferences != nil {
for _, r := range *c.ExternalReferences {
Expand All @@ -101,13 +103,15 @@ func findExternalRef(c *cyclonedx.Component, typ cyclonedx.ExternalReferenceType
return nil
}

//nolint:unused
func refURL(c *cyclonedx.Component, typ cyclonedx.ExternalReferenceType) string {
if r := findExternalRef(c, typ); r != nil {
return r.URL
}
return ""
}

//nolint:unused
func refComment(c *cyclonedx.Component, typ cyclonedx.ExternalReferenceType) string {
if r := findExternalRef(c, typ); r != nil {
return r.Comment
Expand Down
4 changes: 2 additions & 2 deletions sbom/internal/formats/cyclonedx13/cyclonedxhelpers/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func toBomDescriptorComponent(srcMetadata source.Metadata) *cyclonedx.Component
switch srcMetadata.Scheme {
case source.ImageScheme:
bomRef, err := artifact.IDByHash(srcMetadata.ImageMetadata.ID)
if err != nil {
if err != nil { //nolint:staticcheck
// log.Warnf("unable to get fingerprint of image metadata=%s: %+v", srcMetadata.ImageMetadata.ID, err)
}
return &cyclonedx.Component{
Expand All @@ -172,7 +172,7 @@ func toBomDescriptorComponent(srcMetadata source.Metadata) *cyclonedx.Component
}
case source.DirectoryScheme, source.FileScheme:
bomRef, err := artifact.IDByHash(srcMetadata.Path)
if err != nil {
if err != nil { //nolint:staticcheck
// log.Warnf("unable to get fingerprint of source metadata path=%s: %+v", srcMetadata.Path, err)
}
return &cyclonedx.Component{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func encodeGroup(p pkg.Package) string {
return ""
}

//nolint:unused
func decodeGroup(group string, metadata interface{}) {
if meta, ok := metadata.(*pkg.JavaMetadata); ok {
if meta.PomProperties == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func encodeLicenses(p pkg.Package) *cyclonedx.Licenses {
return nil
}

//nolint:unused
func decodeLicenses(c *cyclonedx.Component) (out []string) {
if c.Licenses != nil {
for _, l := range *c.Licenses {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func encodePublisher(p pkg.Package) string {
return ""
}

//nolint:unused
func decodePublisher(publisher string, metadata interface{}) {
switch meta := metadata.(type) {
case *pkg.ApkMetadata:
Expand Down
2 changes: 1 addition & 1 deletion sbom/internal/formats/syft2/to_format_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

func ToFormatModel(s sbom.SBOM) model.Document {
src, err := toSourceModel(s.Source)
if err != nil {
if err != nil { //nolint:staticcheck
// log.Warnf("unable to create syft-json source object: %+v", err)
}

Expand Down
8 changes: 0 additions & 8 deletions sbom/sbom_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ func (f sbomFormat) Extension() string {
}
}

func formatIDs() (ids []sbom.FormatID) {
for _, f := range additionalFormats {
ids = append(ids, f.ID())
}
ids = append(syft.FormatIDs(), ids...)
return ids
}

func formatByMediaType(mediaType string) (sbomFormat, error) {
baseType, params, err := mime.ParseMediaType(mediaType)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion scribe/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func ExampleEmitter_LaunchProcesses() {
// some-type: some-command
// web (default): web-command
// some-other-type: some-other-command some args

//
// Assigning launch processes:
// some-type: some-command
// web (default): web-command
Expand Down

0 comments on commit ca29922

Please sign in to comment.