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

Apply first batch of golangci linters #948

Merged
merged 1 commit into from
Nov 29, 2019
Merged

Apply first batch of golangci linters #948

merged 1 commit into from
Nov 29, 2019

Conversation

saschagrunert
Copy link
Member

We enable and fix the reports of the following linters:

  • deadcode
  • gocritic
  • golint
  • ineffassign
  • maligned
  • prealloc
  • staticcheck
  • unparam
  • unused
  • whitepsace

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Nov 29, 2019
Copy link
Member

@justaugustus justaugustus left a comment

Choose a reason for hiding this comment

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

@saschagrunert -- Linting makes me happy! :)

I've got a few comments for clarification and one nit before approving.

Also, for future PRs, can we have one commit per linter enabled?
e.g.,:

lint: Enable golang `errcheck` linter 

This will make it really easy to back out of any potential breaking changes.
/hold

@@ -106,6 +105,7 @@ linters-settings:
- valSwap
- wrapperFunc
- yodaStyleExpr
# - ifElseChain
Copy link
Member

Choose a reason for hiding this comment

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

Any reason we commented this one out when it was uncommented before?

Copy link
Member Author

Choose a reason for hiding this comment

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

It reports to refactor else-if chains into switch statements, like:

release/pkg/git/git.go

Lines 111 to 122 in af8e773

if err == nil {
// The file or directory exists, just try to update the repo
return updateRepo(repoPath, useSSH)
} else if os.IsNotExist(err) {
// The directory does not exists, we still have to clone it
targetDir = repoPath
} else {
// Something else bad happened
return nil, err
}

I'm not sure if we should do this and I tend to say no. But I'm open to go with the defaults.

Copy link
Member

Choose a reason for hiding this comment

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

Let's leave that one commented out for now.
I'd say once we hit three or more chains and there's a common pattern, maybe consider switch statements, but I don't think we need to nit on it at the moment.

@@ -57,19 +55,3 @@ func init() {
// initConfig reads in config file and ENV variables if set.
func initConfig() {
}

func cleanupTmpDir(dir string) error {
Copy link
Member

Choose a reason for hiding this comment

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

deadcode?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I could also add a nolint if we will need it in the future. Right now the git package takes care of that cleanup.

Copy link
Member

Choose a reason for hiding this comment

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

We'll need a common cleanup function somewhere, that is separate from the git package.
So this is fine right now, but we'll need to address that in a follow-up.

cmd/krel/cmd/push.go Show resolved Hide resolved
pkg/git/git.go Show resolved Hide resolved
pkg/notes/notes.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 29, 2019
@justaugustus
Copy link
Member

/assign
/milestone v1.17
/priority important-longterm
/kind cleanup

@k8s-ci-robot k8s-ci-robot added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Nov 29, 2019
@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Nov 29, 2019
@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Nov 29, 2019
@saschagrunert
Copy link
Member Author

Also, for future PRs, can we have one commit per linter enabled?
e.g.,:

Yeah I thought the same after I opened the PR, sorry for that 😇

We enable and fix the reports of the following linters:

- deadcode
- gocritic
- golint
- ineffassign
- maligned
- prealloc
- staticcheck
- unparam
- unused
- whitepsace

Signed-off-by: Sascha Grunert <[email protected]>
@justaugustus
Copy link
Member

Thanks again, Sascha!
/lgtm
/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 29, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justaugustus, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 29, 2019
@k8s-ci-robot k8s-ci-robot merged commit 19e0734 into kubernetes:master Nov 29, 2019
@k8s-ci-robot k8s-ci-robot modified the milestones: v1.17, v1.18 Nov 29, 2019
@saschagrunert saschagrunert deleted the lints branch November 29, 2019 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. sig/release Categorizes an issue or PR as relevant to SIG Release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants