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

🌱 Remove lint ignore for gocritic #2399

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

MrDXY
Copy link
Contributor

@MrDXY MrDXY commented Sep 27, 2023

What this PR does / why we need it:
Remove //nolint:gocritic linter and fix findings.

  1. Remove nolint:gocritic for /controllers/controllers_suite_test.go
    1. To properly execute the teardown, I remove the defer keyword and place it before the os.Exit(code) statement.
  2. Remove nolint:gocritic for /controllers/vspheremachine_controller.go
    1. To simplify the code, I merge the conditions r.supervisorBased and machineCtx.GetCluster().Status.InfrastructureReady using an else if statement as recommended by gocritic.
  3. Remove nolint:gocritic for pkg/services/govmomi/service.go
    1. Reconstruct the switch logic, and use an if to replace it.
    2. I noticed a TODO comment from @akutz that suggests using a switch instead of an if statement to check metadata encoding. However, I have not seen any follow-ups on this. As everything seems to be working well, I have refactored it to an if structure. If anyone has a better solution or suggestion, or, perhaps I made a mistake, please feel free to comment on this PR.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #2384

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 27, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @MrDXY. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 27, 2023
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 27, 2023
@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (3b7fbc6) 60.79% compared to head (062d607) 60.94%.
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2399      +/-   ##
==========================================
+ Coverage   60.79%   60.94%   +0.14%     
==========================================
  Files         164      164              
  Lines        9473     9465       -8     
==========================================
+ Hits         5759     5768       +9     
+ Misses       3298     3284      -14     
+ Partials      416      413       -3     
Files Coverage Δ
controllers/vspheremachine_controller.go 76.47% <40.00%> (-0.09%) ⬇️
pkg/services/govmomi/service.go 1.25% <0.00%> (+0.01%) ⬆️

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

Looks good - one idea to add comments.

And you managed to fix what looks like a bad bug while you were at it!

controllers/vspheremachine_controller.go Outdated Show resolved Hide resolved
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

One last nit.

:-)

controllers/vspheremachine_controller.go Outdated Show resolved Hide resolved
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 2, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 4dd388b26bb3ddbc8be9c32ace8d18be92292433

@MrDXY
Copy link
Contributor Author

MrDXY commented Oct 10, 2023

Hi folks, do we still have any comments/suggestions or concerns on this PR? If everything looks good, please kindly approve at your convenience.

@chrischdi
Copy link
Member

I'm good with the change, however merging will currently fail due to issues in CI...

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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 Oct 10, 2023
@killianmuldoon
Copy link
Contributor

I'm good with the change, however merging will currently fail due to issues in CI...

Maybe not - do we re-run test runs when we merge? Let's see 🤔

@chrischdi
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot merged commit bbdd599 into kubernetes-sigs:main Oct 10, 2023
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Oct 10, 2023
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants