Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Enabled golangci-lint with staticcheck only and fixed issues #149

Merged
merged 4 commits into from
Oct 28, 2022

Conversation

andresuribe87
Copy link
Contributor

@andresuribe87 andresuribe87 commented Oct 28, 2022

This PR configures and enables golangci-lint in github actions. I intentionally only enabled the staticcheck linter, so this becomes easier to review. The only noteworthy change to highlight was the due to the following warning:

pkg/server/router/dwn.go:82:19: SA4022: the address of a variable cannot be nil (staticcheck)
        if err != nil || &publishManifestResponse.Manifest == nil {

To fix, I changed this to use the IsEmpty() method.

Additional linters will be enabled in a follow up PR.

@codecov-commenter
Copy link

Codecov Report

Merging #149 (011c65b) into main (fc607fb) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##             main     #149   +/-   ##
=======================================
  Coverage   27.79%   27.79%           
=======================================
  Files          20       20           
  Lines        1558     1558           
=======================================
  Hits          433      433           
  Misses       1051     1051           
  Partials       74       74           
Impacted Files Coverage Δ
pkg/server/router/credential.go 5.40% <ø> (ø)
pkg/server/router/dwn.go 17.77% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Manifest manifest.CredentialManifest `json:"manifest" validate:"required"`
DWNResponse dwnpkg.DWNPublishManifestResponse `json:"dwnResponse" validate:"required"`
Manifest *manifest.CredentialManifest `json:"manifest" validate:"required"`
DWNResponse *dwnpkg.DWNPublishManifestResponse `json:"dwnResponse" validate:"required"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd prefer reverting this, required fields should not be nil-able

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@@ -79,20 +79,20 @@ func (dwnr DWNRouter) PublishManifest(ctx context.Context, w http.ResponseWriter
req := request.ToServiceRequest()
publishManifestResponse, err := dwnr.service.GetManifest(req)

if err != nil || &publishManifestResponse.Manifest == nil {
if err != nil || publishManifestResponse.Manifest == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to get around this check we should define an IsEmpty method on Manifest. I think one may even already exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@decentralgabe decentralgabe merged commit 8905a12 into TBD54566975:main Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants