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

chore: add stricter linting #87

Merged

Conversation

djgilcrease
Copy link
Contributor

@djgilcrease djgilcrease commented Oct 10, 2019

These are the errors that were found and fixed

./bin/golangci-lint run --exclude-use-default=false --fix -v
INFO [config_reader] Config search paths: [./ /opt/projects/go/nfpm /opt/projects/go /opt/projects /opt /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 36 linters: [bodyclose deadcode depguard dogsled dupl errcheck funlen gochecknoglobals gochecknoinits gocognit goconst gocritic gocyclo gofmt goimports golint gosec gosimple govet ineffassign interfacer lll maligned misspell nakedret prealloc scopelint staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace] 
INFO [loader] Go packages loading at mode 575 (deps|exports_file|files|types_sizes|compiled_files|name|imports) took 339.823287ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 4.478827ms 
INFO [runner/max_same_issues] 12/15 issues with text "hugeParam: info is heavy (568 bytes); consider passing it by pointer" were hidden, use --max-same-issues 
INFO [runner] Issues before processing: 54, after processing: 14 
INFO [runner] Processors filtering stat (out/in): path_prettifier: 54/54, exclude: 54/54, diff: 26/26, max_from_linter: 14/14, skip_files: 54/54, autogenerated_exclude: 54/54, max_per_file_from_linter: 26/26, source_code: 14/14, cgo: 54/54, identifier_marker: 54/54, exclude-rules: 52/54, nolint: 26/52, uniq_by_line: 26/26, max_same_issues: 14/26, filename_unadjuster: 54/54, skip_dirs: 54/54, path_shortener: 14/14 
INFO [runner] processing took 11.387623ms with stages: nolint: 8.313388ms, identifier_marker: 1.988598ms, path_prettifier: 220.409µs, exclude-rules: 209.314µs, source_code: 193.796µs, autogenerated_exclude: 161.701µs, skip_dirs: 127.282µs, max_same_issues: 94.505µs, cgo: 25.195µs, uniq_by_line: 16.985µs, filename_unadjuster: 14.952µs, max_from_linter: 8.428µs, path_shortener: 6.739µs, max_per_file_from_linter: 4.724µs, exclude: 644ns, diff: 522ns, skip_files: 441ns 
INFO [runner] linters took 1.032264664s with stages: goanalysis_metalinter: 646.924839ms, unused: 373.810741ms 
INFO fixer took 0s with no stages                 
nfpm.go:56:8: shadow: declaration of "err" shadows declaration at line 41 (govet)
	if v, err := semver.NewVersion(config.Info.Version); err == nil {
	      ^
acceptance/placeholder.go:1:1: ST1000: at least one file in a package should have a package comment (stylecheck)
package acceptance
^
glob/glob.go:26:1: paramTypeCombine: func(a string, b string) string could be replaced with func(a, b string) string (gocritic)
func strlcp(a string, b string) string {
^
deb/deb.go:48:21: hugeParam: info is heavy (568 bytes); consider passing it by pointer (gocritic)
func (*Deb) Package(info nfpm.Info, deb io.Writer) (err error) {
                    ^
deb/deb.go:91:22: hugeParam: info is heavy (568 bytes); consider passing it by pointer (gocritic)
func createDataTarGz(info nfpm.Info) (dataTarGz, md5sums []byte, instSize int64, err error) {
                     ^
deb/deb.go:121:29: hugeParam: info is heavy (568 bytes); consider passing it by pointer (gocritic)
func createFilesInsideTarGz(info nfpm.Info, out *tar.Writer, created map[string]bool) (bytes.Buffer, int64, error) {
                            ^
deb/deb.go:245:58: hugeParam: header is heavy (216 bytes); consider passing it by pointer (gocritic)
func newItemInsideTarGz(out *tar.Writer, content []byte, header tar.Header) error {
                                                         ^
deb/deb.go:383:32: hugeParam: data is heavy (576 bytes); consider passing it by pointer (gocritic)
func writeControl(w io.Writer, data controlData) error {
                               ^
deb/deb.go:266:1: paramTypeCombine: func(out *tar.Writer, path string, dest string) error could be replaced with func(out *tar.Writer, path, dest string) error (gocritic)
func newScriptInsideTarGz(out *tar.Writer, path string, dest string) error {
^
rpm/rpm.go:182:2: builtinShadow: shadowing of predeclared identifier: copy (gocritic)
	copy := func(files map[string]string, config bool) error {
	^
rpm/rpm_test.go:102:12: Error return value of `os.Remove` is not checked (errcheck)
		os.Remove(f.Name())
		         ^
acceptance/acceptance_test.go:94:13: Error return value of `os.Setenv` is not checked (errcheck)
			os.Setenv("SEMVER", "v1.0.0-0.1.b1+git.abcdefgh")
			         ^
nfpm.go:64:2: naked return in func `Parse` with 24 lines of code (nakedret)
	return
	^
nfpm.go:105:2: naked return in func `Get` with 15 lines of code (nakedret)
	return
	^
INFO File cache stats: 18 entries of total size 80.1KiB 
INFO Memory: 15 samples, avg is 100.5MB, max is 136.5MB 
INFO Execution took 1.390817233s

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

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

loved it, loved the golangci config, will copy it to goreleaser as well!

thanks

@djgilcrease
Copy link
Contributor Author

loved it, loved the golangci config, will copy it to goreleaser as well!

ok will go fix the new issues found and get the build working :)

@djgilcrease
Copy link
Contributor Author

djgilcrease commented Oct 10, 2019

This has breaking changes for those using nfpm as a library and since I will be away tomorrow (10/10) I will hold off on merging this myself.

eg https://github.com/goreleaser/goreleaser/blob/master/internal/pipe/nfpm/nfpm.go#L145 will need to change to var info = &nfpm.Info{...}

GitHub
Deliver Go binaries as fast and easily as possible - goreleaser/goreleaser

nfpm.go Outdated Show resolved Hide resolved
@caarlos0
Copy link
Member

This has breaking changes for those using nfpm as a library

its fine, I already bumped to 1.0.0-betax...

@codecov-io
Copy link

Codecov Report

Merging #87 into master will increase coverage by 0.06%.
The diff coverage is 85.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
+ Coverage   71.45%   71.51%   +0.06%     
==========================================
  Files           5        5              
  Lines         473      474       +1     
==========================================
+ Hits          338      339       +1     
  Misses         84       84              
  Partials       51       51
Impacted Files Coverage Δ
cmd/nfpm/main.go 0% <ø> (ø) ⬆️
glob/glob.go 94.44% <100%> (ø) ⬆️
rpm/rpm.go 71.22% <100%> (ø) ⬆️
nfpm.go 91.04% <69.23%> (+0.13%) ⬆️
deb/deb.go 72.86% <90.9%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b47eac0...5966868. Read the comment docs.

@djgilcrease djgilcrease merged commit 7889c9b into goreleaser:master Oct 11, 2019
@djgilcrease djgilcrease deleted the bugfix/enable-stricter-linting branch October 11, 2019 20:11
@caarlos0
Copy link
Member

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@goreleaser goreleaser locked as resolved and limited conversation to collaborators Nov 17, 2020
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.

None yet

3 participants