Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <[email protected]>
  • Loading branch information
cpanato committed Mar 30, 2024
1 parent 84dd1ab commit 1b40e65
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 42 deletions.
33 changes: 3 additions & 30 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright 2023 The OpenVEX Authors
# SPDX-License-Identifier: Apache-2.0

---
run:
concurrency: 6
deadline: 5m
issues:
exclude-rules:
# counterfeiter fakes are usually named 'fake_<something>.go'
Expand Down Expand Up @@ -98,22 +100,8 @@ linters-settings:
gocritic:
enabled-checks:
# Diagnostic
- appendAssign
- argOrder
- badCond
- caseOrder
- codegenComment
- commentedOutCode
- deprecatedComment
- dupArg
- dupBranchBody
- dupCase
- dupSubExpr
- exitAfterDefer
- flagDeref
- flagName
- nilValReturn
- offBy1
- sloppyReassign
- weakCond
- octalLiteral
Expand All @@ -127,31 +115,16 @@ linters-settings:
- rangeValCopy

# Style
- assignOp
- boolExprSimplify
- captLocal
- commentFormatting
- commentedOutImport
- defaultCaseOrder
- docStub
- elseif
- emptyFallthrough
- emptyStringTest
- hexLiteral
- methodExprCall
- regexpMust
- singleCaseSwitch
- sloppyLen
- stringXbytes
- switchTrue
- typeAssertChain
- typeSwitchVar
- underef
- unlabelStmt
- unlambda
- unslice
- valSwap
- wrapperFunc
- yodaStyleExpr
# - ifElseChain

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ to preserve the original file, specify it using the --file flag:
SilenceUsage: false,
SilenceErrors: true,
PersistentPreRunE: initLogging,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
// If we have arguments, add them
for i := range args {
switch i {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Examples:
SilenceUsage: false,
SilenceErrors: true,
PersistentPreRunE: initLogging,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
// If we have arguments, add them
for i := range args {
switch i {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ using its canonicalization hash.
SilenceUsage: false,
SilenceErrors: true,
PersistentPreRunE: initLogging,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
if len(args) > 0 {
if opts.Product != "" && opts.Product != args[0] {
return errors.New("product can only be specified once")
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Examples:
SilenceUsage: false,
SilenceErrors: false,
PersistentPreRunE: initLogging,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
if len(args) == 0 {
return fmt.Errorf("selection of 'status' or 'justification' is required")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Examples:
SilenceUsage: false,
SilenceErrors: false,
PersistentPreRunE: initLogging,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
vexctl := ctl.New()

// TODO(puerco): Change this to vex merge options when we move
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestAddOptionsValidate(t *testing.T) {
}{
{
name: "no-error",
prepare: func(ao *addOptions) {},
prepare: func(_ *addOptions) {},
sut: &addOptions{
vexStatementOptions: stubOpts,
documentPath: filepath.Join(d, "openvex.test"),
Expand All @@ -141,7 +141,7 @@ func TestAddOptionsValidate(t *testing.T) {
},
{
name: "inplace-and-outfile",
prepare: func(ao *addOptions) {},
prepare: func(_ *addOptions) {},
sut: &addOptions{
vexStatementOptions: stubOpts,
outFileOption: outFileOption{
Expand Down
9 changes: 5 additions & 4 deletions pkg/ctl/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,9 @@ func (impl *defaultVexCtlImplementation) NormalizeProducts(subjects []productRef
if pref.Hashes == nil {
pref.Hashes = make(map[vex.Algorithm]vex.Hash)
}
if strings.HasPrefix(pref.Name, "pkg:oci/") ||
strings.HasPrefix(pref.Name, "pkg:/oci/") { // Some buggy tools add this wrong slash
switch {
case strings.HasPrefix(pref.Name, "pkg:/oci/"),
strings.HasPrefix(pref.Name, "pkg:oci/"):
// Deduct image purls to the reference as much as possible
p, err := purl.FromString(pref.Name)
if err != nil {
Expand Down Expand Up @@ -577,15 +578,15 @@ func (impl *defaultVexCtlImplementation) NormalizeProducts(subjects []productRef
pref.Name = ref
logrus.Debugf("%s is a purl for %s", pref.Name, ref)
imageRefs = append(imageRefs, pref)
} else if strings.HasPrefix(pref.Name, "pkg:") {
case strings.HasPrefix(pref.Name, "pkg:"):
// When there are other purls, we only attest them as subjects if
// the product reference has hashes
if pref.Hashes != nil && len(pref.Hashes) > 0 {
otherRefs = append(otherRefs, pref)
} else {
unattestableRefs = append(unattestableRefs, pref)
}
} else {
default:
// If not,try to parse the string as an image reference. If they can
// be parsed as image references but they cannot be looked up, attestting
// will fail trying to fetch their digests.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/implementation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func TestInitTemplatesDir(t *testing.T) {
}{
{
name: "normal",
prepare: func(s string) {},
prepare: func(_ string) {},
shouldErr: false,
},
{
Expand Down

0 comments on commit 1b40e65

Please sign in to comment.