Skip to content

Commit

Permalink
Enable errcheck linter
Browse files Browse the repository at this point in the history
  • Loading branch information
phillebaba committed Jun 11, 2024
1 parent fd45291 commit 36d36dc
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ run:
linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
Expand Down Expand Up @@ -54,6 +55,12 @@ linters-settings:
- name: redefines-builtin-id
testifylint:
enable-all: true
errcheck:
exclude-functions:
- (*github.com/spf13/cobra.Command).Help
- (*github.com/spf13/cobra.Command).MarkFlagRequired
- (*github.com/spf13/pflag.FlagSet).MarkHidden
- (*github.com/spf13/pflag.FlagSet).MarkDeprecated
issues:
# Revive rules that are disabled by default.
include:
Expand Down
1 change: 1 addition & 0 deletions src/internal/agent/http/admission/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (h *Handler) Serve(hook operations.Hook) http.HandlerFunc {

message.Infof(lang.AgentInfoWebhookAllowed, r.URL.Path, review.Request.Operation, result.Allowed)
w.WriteHeader(http.StatusOK)
// nolint: errcheck // ignore
w.Write(jsonResponse)
}
}
1 change: 1 addition & 0 deletions src/internal/agent/http/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func ProxyHandler() http.HandlerFunc {
if err != nil {
message.Debugf("%#v", err)
w.WriteHeader(http.StatusInternalServerError)
// nolint: errcheck // ignore
w.Write([]byte(lang.AgentErrUnableTransform))
return
}
Expand Down
1 change: 1 addition & 0 deletions src/internal/agent/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func NewProxyServer(port string) *http.Server {
func healthz() http.HandlerFunc {
return func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
// nolint: errcheck // ignore
w.Write([]byte("ok"))
}
}
1 change: 1 addition & 0 deletions src/pkg/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ func Table(header []string, data [][]string) {
table = append(table, pterm.TableData{row}...)
}

// nolint:errcheck // never returns an error
pterm.DefaultTable.WithHasHeader().WithData(table).Render()
}

Expand Down
1 change: 1 addition & 0 deletions src/pkg/packager/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func fillComponentTemplate(validator *Validator, node *composer.Node, createOpts
// [DEPRECATION] Set the Package Variable syntax as well for backward compatibility
setVarsAndWarn(types.ZarfPackageVariablePrefix, true)

//nolint: errcheck // This error should bubble up
utils.ReloadYamlTemplate(node, templateMap)
}

Expand Down
5 changes: 4 additions & 1 deletion src/pkg/zoci/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ func (r *Remote) PublishPackage(ctx context.Context, pkg *types.ZarfPackage, pat

// assumes referrers API is not supported since OCI artifact
// media type is not supported
r.Repo().SetReferrersCapability(false)
err = r.Repo().SetReferrersCapability(false)
if err != nil {
return err

Check warning on line 58 in src/pkg/zoci/push.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/zoci/push.go#L56-L58

Added lines #L56 - L58 were not covered by tests
}

// push the manifest config
manifestConfigDesc, err := r.CreateAndPushManifestConfig(ctx, annotations, ZarfConfigMediaType)
Expand Down
3 changes: 2 additions & 1 deletion src/test/nightly/ecr_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func TestECRPublishing(t *testing.T) {
t.Log("E2E: Testing component actions")

// Work from the root directory of the project
os.Chdir("../../../")
err := os.Chdir("../../../")
require.NoError(t, err)

// Create a tmpDir for us to use during this test
tmpDir := t.TempDir()
Expand Down

0 comments on commit 36d36dc

Please sign in to comment.