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

Resolve linter errors when running make against clean repo #9460

Closed
4 tasks
augchan42 opened this issue Jun 4, 2021 · 3 comments · Fixed by #9464
Closed
4 tasks

Resolve linter errors when running make against clean repo #9460

augchan42 opened this issue Jun 4, 2021 · 3 comments · Fixed by #9464

Comments

@augchan42
Copy link
Contributor

augchan42 commented Jun 4, 2021

Summary of Bug

When running make for the first time from a freshly cloned repo, there's many gofmt errors and a gocritic appendAssign error. Ideally a make should complete with no changes from a freshly cloned repo.

Version

https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.5

Steps to Reproduce

My build OS is banner is: Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-73-generic x86_64)
After cloning the repo (e.g., 'gh repo clone cosmos/cosmos-sdk'), run 'make'. You will need to setup your environment with all pre-reqs (golangci-lint, golang-go, make, docker-ce, etc)

Here's a portion of the errors:

ubuntu@primary:~/Home/cosmos-sdk$ make
# Create dummy file to satisfy dependency and avoid
# rebuilding when this Makefile target is hit twice
# in a row.
touch tools-stamp
mkdir -p /home/ubuntu/Home/cosmos-sdk/build/
go build -mod=readonly -tags "netgo ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version=0.43.0-beta1-62-gd14398f84 -X github.com/cosmos/cosmos-sdk/version.Commit=d14398f849ec184684b22e0dcb61fa3cd33d51b3 -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" -X github.com/tendermint/tendermint/version.TMCoreSemVer=v0.34.10 -w -s' -trimpath -o /home/ubuntu/Home/cosmos-sdk/build/ ./...
golangci-lint run --out-format=tab
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner.  Replaced by revive.
x/distribution/legacy/v043/helpers.go:22:18            gocritic  appendAssign: append result not assigned to the same slice
types/grpc/headers.go:1                                gofmt     File is not `gofmt`-ed with `-s`
x/upgrade/exported/exported.go:1                       gofmt     File is not `gofmt`-ed with `-s`
x/bank/legacy/v038/types.go:1                          gofmt     File is not `gofmt`-ed with `-s`
internal/conv/doc.go:1                                 gofmt     File is not `gofmt`-ed with `-s`
internal/conv/string.go:1                              gofmt     File is not `gofmt`-ed with `-s`
x/genutil/legacy/v039/types.go:1                       gofmt     File is not `gofmt`-ed with `-s`
types/bech32/bech32.go:1                               gofmt     File is not `gofmt`-ed with `-s`

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@augchan42
Copy link
Contributor Author

I thought it might be due to timeout, but I increased my timeout in golangci.yml to 5 minutes and still encounter these errors.

@augchan42
Copy link
Contributor Author

augchan42 commented Jun 4, 2021

Additional errors after resolving the above:

golangci-lint run --out-format=tab
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner.  Replaced by revive.
docs/core/encoding.md:201:163 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
docs/DOC_WRITING_GUIDELINES.md:12 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]
docs/DOC_WRITING_GUIDELINES.md:13 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 3]

@augchan42
Copy link
Contributor Author

augchan42 commented Jun 4, 2021

Proposed fix for: x/distribution/legacy/v043/helpers.go:22:18 gocritic appendAssign: append result not assigned to the same slice

OLD CODE:
newStoreKey := append(prefixBz, address.MustLengthPrefix(addr)...)

NEW CODE:
var newStoreKey []byte = prefixBz
newStoreKey = append(newStoreKey, address.MustLengthPrefix(addr)...)

@augchan42 augchan42 changed the title Many gofmt/gocritic errors when trying to make Resolve linter errors when running make against clean repo Jun 5, 2021
@mergify mergify bot closed this as completed in #9464 Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant