Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gometalinter -> golangci-lint migration #3933

Merged
merged 15 commits into from
Mar 19, 2019
Merged

Conversation

alessio
Copy link
Contributor

@alessio alessio commented Mar 18, 2019

{,scripts/}Makefile:
- Remove gometalinter, install golangci-lint.
- Remove distinction between tools and devtools.
  Just tools is enough.
- test_lint -> lint
  Migrating away from underscore separated names.
- Remove unnecessary targets.
- Drop tendermint/lint. Incompatbile with golangci-lint
  and no longer necessary anyway.

Port tools/gometalinter.json to .golangci.yml
Update CircleCI config accordingly.

Closes: #3896
Also addresses #2835

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote tests
  • Updated relevant documentation (docs/)
  • Added a relevant changelog entry: sdkch add [section] [stanza] [message]
  • rereviewed Files changed in the github PR explorer

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented Mar 18, 2019

Codecov Report

Merging #3933 into develop will decrease coverage by 0.04%.
The diff coverage is 13.63%.

@@             Coverage Diff             @@
##           develop    #3933      +/-   ##
===========================================
- Coverage    60.26%   60.22%   -0.05%     
===========================================
  Files          196      197       +1     
  Lines        14615    14628      +13     
===========================================
+ Hits          8808     8809       +1     
- Misses        5214     5225      +11     
- Partials       593      594       +1

{,scripts/}Makefile:
- Remove gometalinter, install golangci-lint.
- Remove distinction between tools and devtools.
  Just tools is enough.
- test_lint -> lint
  Migrating away from underscore separated names.
- Remove unnecessary targets.
- Drop tendermint/lint. Incompatbile with golangci-lint
  and no longer necessary anyway.

Port tools/gometalinter.json to .golangci.yml
Update CircleCI config accordingly.

Closes: #3896
Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

couple minor things - thanks for this

@@ -337,7 +337,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress

cleanup = func() {
logger.Debug("cleaning up LCD initialization")
node.Stop()
node.Stop() //nolint:errcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still have nolint??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

client/rpc/status.go Outdated Show resolved Hide resolved
@@ -43,7 +43,7 @@ $ gaiacli query gov proposal 1

var proposal gov.Proposal
cdc.MustUnmarshalJSON(res, &proposal)
return cliCtx.PrintOutput(proposal)
return cliCtx.PrintOutput(proposal) // nolint:errcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this errcheck suppression for lines like these? Is there anything we can do to fix this lint issue? what's causing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PrintOutput() returns err

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a bug in errcheck to me...

Copy link
Contributor

Choose a reason for hiding this comment

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

if

if err := cliCtx.PrintOutput(proposal); err != nil {
return err
} 
return nil 

is not an error but what we have is an error, then yes, it looks like an errcheck bug to me

@alessio alessio added the tooling dev tooling within the sdk label Mar 19, 2019
Copy link
Contributor

@sabau sabau left a comment

Choose a reason for hiding this comment

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

👍 simplification is always nice.
Would be great to find a way to remove the lint ignore

Makefile Outdated Show resolved Hide resolved
Copy link
Contributor

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

I left a few comments. The PR LGTM (especially that it simplifies the Makefile) 👍

The only thing to reconsider: The file install-golangci.sh should probably be downloaded during setup time instead of copied from the golangci-lint repository: https://github.com/golangci/golangci-lint/blob/master/install.sh (note the License there)

Drop tendermint/lint. Incompatbile with golangci-lint
and no longer necessary anyway.

Question: Does that mean we can delete/archive this repo?

// DeleteKeyReq requests deleting a key
type DeleteKeyReq struct {
Password string `json:"password"`
}

// NewDeleteKeyReq constructs a new DeleteKeyReq structure.
func NewDeleteKeyReq(password string) DeleteKeyReq { return DeleteKeyReq{Password: password} }
Copy link
Contributor

Choose a reason for hiding this comment

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

In go usually anything New* returns a pointer to the struct though, no? Meaning return &DeleteKeyReq{} here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In go usually anything New* returns a pointer to the struct though, no?

I used to believe so. Apparently the use of the New prefix is idiomatic regardless of whether the function returns a struct or a pointer.

@@ -145,7 +145,9 @@ func fingerprintForCertificate(certBytes []byte) (string, error) {
return "", err
}
h := sha256.New()
h.Write(cert.Raw)
if _, err := h.Write(cert.Raw); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: sha256's write actually doesn't err. This is perfect for a nolint with a comment.

See: https://golang.org/src/crypto/sha256/sha256.go?s=4118:4138#L203

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! Nice catch, didn't know about that, thanks! Nonetheless, certificates.go will be gone shortly - we intend to remove the --secure option from the REST server altogether.

@@ -43,7 +43,7 @@ $ gaiacli query gov proposal 1

var proposal gov.Proposal
cdc.MustUnmarshalJSON(res, &proposal)
return cliCtx.PrintOutput(proposal)
return cliCtx.PrintOutput(proposal) // nolint:errcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a bug in errcheck to me...

tools/install-golangci.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

ACK; new linter & Makefile scripts all seem to work. One minor comment.

Makefile Show resolved Hide resolved
@@ -200,6 +225,9 @@ jobs:
- checkout
- *dependencies
- run: mkdir -p /tmp/logs
- restore_cache:
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit too much of restore_cache, should happen only in the required job, in this case setup_dependencies

Copy link
Contributor

Choose a reason for hiding this comment

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

and when installing/downloading occurs.
I'll double check now to be sure which of those should keep it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

setup_dependencies is a job that runs only once. Other jobs need to restore the cache indipendently.

Copy link
Contributor

Choose a reason for hiding this comment

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

but are all of them using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@alessio alessio merged commit cdf2b7a into develop Mar 19, 2019
@alessio alessio deleted the alessio/golangci-lint branch March 19, 2019 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling dev tooling within the sdk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants