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

all: fix go-critic linter suggestions #2440

Merged
merged 1 commit into from Aug 6, 2018

Conversation

cristaloleg
Copy link
Contributor

Fix some warning that were found by go-critic like redundant dereference, shadowed builtins, not using named consts, redundant parentheses.
Log:

check-package: github.com/ncw/rclone/fstest/test_all/test_all.go:175:46: underef: could simplify (*timeout).String to timeout.String

check-package: github.com/ncw/rclone/backend/yandex/api/performdelete.go:32:73: unslice: could simplify body[:] to body
check-package: github.com/ncw/rclone/backend/yandex/api/performdownload.go:37:80: unslice: could simplify body[:] to body
check-package: github.com/ncw/rclone/backend/yandex/api/performmkdir.go:31:34: unslice: could simplify body[:] to body
check-package: github.com/ncw/rclone/backend/yandex/api/performmkdir.go:31:114: unslice: could simplify body[:] to body
check-package: github.com/ncw/rclone/backend/yandex/api/performupload.go:35:73: unslice: could simplify body[:] to body
check-package: github.com/ncw/rclone/fstest/test_all/test_all.go:229:13: unslice: could simplify t.cmdLine[:] to t.cmdLine
check-package: github.com/ncw/rclone/backend/azureblob/azureblob.go:834:17: unslice: could simplify info.Properties.ContentMD5[:] to info.Properties.ContentMD5
check-package: github.com/ncw/rclone/backend/onedrive/quickxorhash/quickxorhash_test.go:143:26: unslice: could simplify got[:] to got

check-package: github.com/ncw/rclone/vfs/read_write_test.go:579:27: namedConst: use time.November instead of 11
check-package: github.com/ncw/rclone/vfs/write_test.go:229:27: namedConst: use time.November instead of 11
check-package: github.com/ncw/rclone/cmd/mountlib/mounttest/dir.go:146:27: namedConst: use time.November instead of 11
check-package: github.com/ncw/rclone/cmd/mountlib/mounttest/file.go:19:27: namedConst: use time.November instead of 11
check-package: github.com/ncw/rclone/cmd/mountlib/mounttest/file.go:44:27: namedConst: use time.November instead of 11
check-package: github.com/ncw/rclone/backend/crypt/cipher_test.go:27:33: namedConst: use NameEncryptionOff instead of 0

check-package: github.com/ncw/rclone/fs/fs.go:631:2: builtinShadow: shadowing of predeclared identifier: copy
check-package: github.com/ncw/rclone/backend/box/box.go:671:2: builtinShadow: shadowing of predeclared identifier: copy
check-package: github.com/ncw/rclone/vfs/read_write.go:264:2: builtinShadow: shadowing of predeclared identifier: copy
check-package: github.com/ncw/rclone/fs/operations/operations.go:985:2: builtinShadow: shadowing of predeclared identifier: delete
check-package: github.com/ncw/rclone/cmd/mount/dir.go:192:82: builtinShadow: shadowing of predeclared identifier: new
check-package: github.com/ncw/rclone/fs/fshttp/http_test.go:18:2: builtinShadow: shadowing of predeclared identifier: new
check-package: github.com/ncw/rclone/fs/config/config.go:935:47: builtinShadow: shadowing of predeclared identifier: new
check-package: github.com/ncw/rclone/backend/crypt/crypt.go:707:2: builtinShadow: shadowing of predeclared identifier: new
check-package: github.com/ncw/rclone/backend/onedrive/onedrive.go:841:2: builtinShadow: shadowing of predeclared identifier: copy

check-package: github.com/ncw/rclone/fs/config/configmap/configmap_test.go:10:13: typeUnparen: could simplify (Simple) to Simple
check-package: github.com/ncw/rclone/fs/config/configmap/configmap_test.go:11:13: typeUnparen: could simplify (Simple) to Simple
check-package: github.com/ncw/rclone/fs/config/configmap/configmap_test.go:12:13: typeUnparen: could simplify (Simple) to Simple
check-package: github.com/ncw/rclone/backend/b2/api/types.go:77:7: typeUnparen: could simplify (time.Time) to time.Time
check-package: github.com/ncw/rclone/backend/b2/api/types.go:110:9: typeUnparen: could simplify (time.Time) to time.Time
check-package: github.com/ncw/rclone/backend/b2/api/types.go:117:5: typeUnparen: could simplify (time.Time) to time.Time
check-package: github.com/ncw/rclone/backend/b2/api/types.go:120:5: typeUnparen: could simplify (time.Time) to time.Time
check-package: github.com/ncw/rclone/backend/b2/api/types.go:123:9: typeUnparen: could simplify (time.Time) to time.Time
check-package: github.com/ncw/rclone/backend/b2/api/types.go:123:30: typeUnparen: could simplify (time.Time) to time.Time
check-package: github.com/ncw/rclone/fs/fserrors/error.go:56:35: typeUnparen: could simplify (error) to error
check-package: github.com/ncw/rclone/fs/fserrors/error.go:100:35: typeUnparen: could simplify (error) to error
check-package: github.com/ncw/rclone/fs/fserrors/error.go:148:39: typeUnparen: could simplify (error) to error

@ncw
Copy link
Member

ncw commented Aug 6, 2018

That looks great - thank you for taking the time to fix those.

Do you think we should run those checks as part of CI? How long do they take?

We could adjust the build_dep and check targets in the Makefile to install go-critic and run it - do you think that is a good idea? If so then please send a PR!

I'll merge the above - it looks sensible to me!

@ncw ncw merged commit 06c9f76 into rclone:master Aug 6, 2018
@cristaloleg cristaloleg deleted the all/fix-lint-suggestions branch August 6, 2018 21:54
@cristaloleg
Copy link
Contributor Author

Glad to hear that you liked it!

As one of go-criitc's authors I'll be happy to see it running on a regular CI build.
It's fast, simple and informative, so it's harmless 🙌

Will make a PR unless @quasilyte has objections.

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 this pull request may close these issues.

None yet

2 participants