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

Various linting issues detected by nilness, shadow govet analyzers #613

Closed
atc0005 opened this issue Jan 26, 2022 · 0 comments · Fixed by #614
Closed

Various linting issues detected by nilness, shadow govet analyzers #613

atc0005 opened this issue Jan 26, 2022 · 0 comments · Fixed by #614
Assignees
Labels
bug Something isn't working linting
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Jan 26, 2022

Results of the Lint codebase using Makefile CI job from #612:

Running linting tools ...
Running go vet ...
Running golangci-lint ...
level=warning msg="[runner] The linter 'maligned' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.  Replaced by govet 'fieldalignment'."
internal/vsphere/attributes.go:269:17: nilness: tautological condition: non-nil != nil (govet)
		case caValErr != nil:
		              ^
internal/vsphere/snapshots.go:1076:16: nilness: tautological condition: non-nil != nil (govet)
			case parent != nil:
			            ^
internal/vsphere/get.go:277:6: shadow: declaration of "err" shadows declaration at line 260 (govet)
		if err := v.Destroy(ctx); err != nil {
		   ^
internal/vsphere/vms.go:2070:3: shadow: declaration of "numCurrentBackups" shadows declaration at line 2063 (govet)
		numCurrentBackups := numWithBackups - numWithOldBackups
		^
make: *** [Makefile:143: linting] Error 1
Error: Process completed with exit code 2.
@atc0005 atc0005 added bug Something isn't working linting labels Jan 26, 2022
@atc0005 atc0005 added this to the Next Maintenance Release milestone Jan 26, 2022
@atc0005 atc0005 self-assigned this Jan 26, 2022
atc0005 added a commit that referenced this issue Jan 26, 2022
- ignore shadowing warning for `err` variable within if statement
  that wraps deferred view destruction
  - alternative here is to use a name error return value and
    return the view destruction failure result if `err` is not
    already set to another value
  - library devs don't check the error return value for the
    view destruction attempt, which signals to me that the risk
    of it failing is very, very low
- fix unintentional shadowing (essentially "NOOP" scenario) from
  minor refactoring
- replace explicit case statements with default case to resolve
  "tautological" conditions

refs GH-613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant