Skip to content

Commit

Permalink
fix: linter issues
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <[email protected]>
  • Loading branch information
knqyf263 committed Apr 16, 2024
1 parent 61eddab commit 025e73f
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/pkg/dpkg/copyright.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (a *dpkgLicenseAnalyzer) parseCopyright(r xio.ReadSeekerAt) ([]types.Licens
l := strings.TrimSpace(line[8:])

l = normalizeLicense(l)
if len(l) > 0 {
if l != "" {
for _, lic := range licensing.SplitLicenses(l) {
lic = licensing.Normalize(lic)
if !slices.Contains(licenses, lic) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/walker/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package walker

import (
"errors"
xio "github.com/aquasecurity/trivy/pkg/x/io"
"io/fs"
"os"
"path/filepath"
Expand All @@ -11,6 +10,7 @@ import (
"golang.org/x/xerrors"

"github.com/aquasecurity/trivy/pkg/log"
xio "github.com/aquasecurity/trivy/pkg/x/io"
)

// FS is the filesystem walker
Expand Down
2 changes: 1 addition & 1 deletion pkg/flag/report_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (f *ReportFlagGroup) ToOptions() (ReportOptions, error) {
}

func loadComplianceTypes(compliance string) (spec.ComplianceSpec, error) {
if len(compliance) > 0 && !slices.Contains(types.SupportedCompliances, compliance) && !strings.HasPrefix(compliance, "@") {
if compliance != "" && !slices.Contains(types.SupportedCompliances, compliance) && !strings.HasPrefix(compliance, "@") {
return spec.ComplianceSpec{}, xerrors.Errorf("unknown compliance : %v", compliance)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/iac/rules/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func GetFrameworkRules(fw ...framework.Framework) []ruleTypes.RegisteredRule {
}

func GetSpecRules(spec string) []ruleTypes.RegisteredRule {
if len(spec) > 0 {
if spec != "" {
return coreRegistry.getSpecRules(spec)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/iac/scanners/azure/functions/first.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func First(args ...interface{}) interface{} {

switch cType := container.(type) {
case string:
if len(cType) > 0 {
if cType != "" {
return string(cType[0])
}
case interface{}:
Expand Down
2 changes: 1 addition & 1 deletion pkg/iac/scanners/azure/functions/last.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func Last(args ...interface{}) interface{} {

switch cType := container.(type) {
case string:
if len(cType) > 0 {
if cType != "" {
return string(cType[len(cType)-1])
}
case interface{}:
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8s/commands/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func namespaceRun(ctx context.Context, opts flag.Options, cluster k8s.Cluster) e
}

func getNamespace(opts flag.Options, currentNamespace string) string {
if len(opts.K8sOptions.Namespace) > 0 {
if opts.K8sOptions.Namespace != "" {
return opts.K8sOptions.Namespace
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/mapfs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (m *FS) RemoveAll(path string) error {

func cleanPath(path string) string {
// Convert the volume name like 'C:' into dir like 'C\'
if vol := filepath.VolumeName(path); len(vol) > 0 {
if vol := filepath.VolumeName(path); vol != "" {
newVol := strings.TrimSuffix(vol, ":")
newVol = fmt.Sprintf("%s%c", newVol, filepath.Separator)
path = strings.Replace(path, vol, newVol, 1)
Expand Down
2 changes: 1 addition & 1 deletion pkg/report/table/vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *vulnerabilityRenderer) setVulnerabilityRows(tw *table.Table, vulns []ty
title = strings.Join(splitTitle[:12], " ") + "..."
}

if len(v.PrimaryURL) > 0 {
if v.PrimaryURL != "" {
if r.isTerminal {
title = tml.Sprintf("%s\n<blue>%s</blue>", title, v.PrimaryURL)
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sbom/cyclonedx/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (*Marshaler) Properties(properties []core.Property) *[]cdx.Property {
cdxProps := make([]cdx.Property, 0, len(properties))
for _, property := range properties {
namespace := Namespace
if len(property.Namespace) > 0 {
if property.Namespace != "" {
namespace = property.Namespace
}

Expand Down

0 comments on commit 025e73f

Please sign in to comment.