Skip to content

Commit 25bd0f0

Browse files
authored
Bump linter version and fix all nits (#418)
* Bump linter to v2.12 Signed-off-by: Adolfo Garcia Veytia (puerco) <puerco@carabiner.dev> * Fix all linter nits Signed-off-by: Adolfo Garcia Veytia (puerco) <puerco@carabiner.dev> --------- Signed-off-by: Adolfo Garcia Veytia (puerco) <puerco@carabiner.dev>
1 parent 193a514 commit 25bd0f0

21 files changed

Lines changed: 67 additions & 45 deletions

.github/workflows/golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
- name: Run golangci-lint
4040
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
4141
with:
42-
version: v2.11
42+
version: v2.12

.golangci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ linters:
6060
- godox
6161
- goheader
6262
- gomoddirectives
63-
- gomodguard
63+
- gomodguard_v2
6464
- goprintffuncname
6565
- gosec
6666
- gosmopolitan
@@ -110,6 +110,9 @@ linters:
110110
- zerologlint
111111

112112
settings:
113+
goconst:
114+
# Repeated literals in table driven tests don't warrant constants.
115+
ignore-tests: true
113116
gocyclo:
114117
min-complexity: 35
115118
godox:

internal/cmd/audit.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,34 @@ const (
2323
const (
2424
statusPassed = "passed"
2525
statusFailed = "failed"
26+
27+
auditModeBasicName = "basic"
28+
auditModeFullName = "full"
2629
)
2730

2831
// Enable audit mode enum
2932
// String is used both by fmt.Print and by Cobra in help text
3033
func (e *AuditMode) String() string {
3134
switch *e {
3235
case AuditModeBasic:
33-
return "basic"
36+
return auditModeBasicName
3437
case AuditModeFull:
35-
return "full"
38+
return auditModeFullName
3639
}
3740
return "error"
3841
}
3942

4043
// Set must have pointer receiver so it doesn't change the value of a copy
4144
func (e *AuditMode) Set(v string) error {
4245
switch v {
43-
case "basic":
46+
case auditModeBasicName:
4447
*e = AuditModeBasic
4548
return nil
46-
case "full":
49+
case auditModeFullName:
4750
*e = AuditModeFull
4851
return nil
4952
default:
50-
return errors.New(`must be one of "foo", "bar", or "moo"`)
53+
return fmt.Errorf("must be one of %q or %q", auditModeBasicName, auditModeFullName)
5154
}
5255
}
5356

@@ -119,7 +122,7 @@ func addAudit(parentCmd *cobra.Command) {
119122
opts := &auditOpts{}
120123
auditCmd := &cobra.Command{
121124
Use: "audit",
122-
GroupID: "verification",
125+
GroupID: cmdGroupVerification,
123126
Short: "Verifies multiple commits in the branch history",
124127
Long: `Checks the revisions on the specified branch within the repository.
125128

internal/cmd/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var colorHiRed = color.New(color.FgHiRed).SprintFunc()
1818

1919
func addAuth(parentCmd *cobra.Command) {
2020
authCmd := &cobra.Command{
21-
GroupID: "configuration",
21+
GroupID: cmdGroupConfiguration,
2222
Short: "Manage user authentication",
2323
Use: "auth",
2424
SilenceUsage: false,

internal/cmd/checklevel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func addCheckLevel(parentCmd *cobra.Command) {
4444

4545
checklevelCmd := &cobra.Command{
4646
Use: "checklevel",
47-
GroupID: "assessment",
47+
GroupID: cmdGroupAssessment,
4848
Short: "Determines the SLSA Source Level of the repo",
4949
Long: `Determines the SLSA Source Level of the repo.
5050

internal/cmd/checklevelprov.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func addCheckLevelProv(parentCmd *cobra.Command) {
8989

9090
checklevelprovCmd := &cobra.Command{
9191
Use: "checklevelprov",
92-
GroupID: "assessment",
92+
GroupID: cmdGroupAssessment,
9393
Example: `sourcetool checklevelprov owner/repo --push=note`,
9494
Short: "Checks the given commit against policy using & creating provenance",
9595
Long: `Checks the given commit against policy using & creating provenance.

internal/cmd/checktag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func addCheckTag(parentCmd *cobra.Command) {
5555

5656
checktagCmd := &cobra.Command{
5757
Use: "checktag",
58-
GroupID: "assessment",
58+
GroupID: cmdGroupAssessment,
5959
Short: "Checks to see if the tag operation should be allowed and issues a VSA",
6060
PreRunE: func(cmd *cobra.Command, args []string) error {
6161
if len(args) > 0 {

internal/cmd/createpolicy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func addCreatePolicy(parentCmd *cobra.Command) {
3131

3232
createpolicyCmd := &cobra.Command{
3333
Use: "createpolicy",
34-
GroupID: "policy",
34+
GroupID: cmdGroupPolicy,
3535
Short: "Creates a policy in a local copy of source-policies",
3636
Long: `Creates a SLSA source policy in a local copy of source-policies.
3737

internal/cmd/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (pco *policyCreateOpts) AddFlags(cmd *cobra.Command) {
3939

4040
func addPolicy(parentCmd *cobra.Command) {
4141
policyCmd := &cobra.Command{
42-
GroupID: "policy",
42+
GroupID: cmdGroupPolicy,
4343
Short: "tools to work with source policies",
4444
Long: fmt.Sprintf(`
4545
%s %s

internal/cmd/prov.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func addProv(parentCmd *cobra.Command) {
3939
opts := provOptions{}
4040
provCmd := &cobra.Command{
4141
Use: "prov",
42-
GroupID: "assessment",
42+
GroupID: cmdGroupAssessment,
4343
Short: "Creates provenance for the given commit, but does not check policy.",
4444
PreRunE: func(cmd *cobra.Command, args []string) error {
4545
if len(args) > 0 {

0 commit comments

Comments
 (0)