Skip to content

Conversation

@mboersma
Copy link
Contributor

@mboersma mboersma commented Apr 16, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Updates golangci-lint to v2.1.2.

This involved migrating the config file to v2 format, removing two linters that are now unsupported (gosimple and stylecheck), and updating a few bits of code.

Some golangci-lint command-line arguments have changed. In particular, there is no longer a --fast=[true|false] flag, only a --fast-only flag that runs a quick subset of all linters. So I added a make lint-fast target for clarity, and now make lint and make lint-full are the same target. I think this is fine because the new tool seems much faster than the v1.x versions, but let me know what you think.

Which issue(s) this PR fixes:

Refs #5549

Special notes for your reviewer:

v2 migration guide: https://golangci-lint.run/product/migration-guide/

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • cherry-pick candidate

Release note:

NONE

@mboersma mboersma requested review from nawazkh and willie-yao April 16, 2025 21:53
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Apr 16, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 16, 2025
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 16, 2025
@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 52.87%. Comparing base (00f8102) to head (8996658).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
azure/services/aksextensions/spec.go 33.33% 2 Missing ⚠️
api/v1beta1/azuremanagedcontrolplane_webhook.go 66.66% 1 Missing ⚠️
api/v1beta1/azuremanagedmachinepool_webhook.go 0.00% 0 Missing and 1 partial ⚠️
azure/services/scalesets/spec.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5566   +/-   ##
=======================================
  Coverage   52.86%   52.87%           
=======================================
  Files         272      272           
  Lines       29474    29473    -1     
=======================================
+ Hits        15582    15583    +1     
- Misses      13080    13083    +3     
+ Partials      812      807    -5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mboersma mboersma force-pushed the bump-golangci-lint branch from b0ab31d to 8996658 Compare April 16, 2025 22:05
@mboersma mboersma removed the request for review from marosset April 16, 2025 22:22
@mboersma mboersma moved this from Todo to Needs Review in CAPZ Planning Apr 16, 2025
.PHONY: lint-latest ## TODO: update the lint-latest to lint-azure-latest
lint-latest:
./hack/lint-latest.sh ## TODO: update the lint-latest.sh to lint-azure-latest.sh
.PHONY: lint-azure-latest ## Check for usage of the "latest" floating Azure API version.
Copy link
Member

Choose a reason for hiding this comment

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

Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had been ignoring this TODO that gets printed every time you lint, but once I looked at it I understood what @devigned meant.


for _, char := range *name {
if !(unicode.IsLower(char) || unicode.IsNumber(char)) {
if !unicode.IsLower(char) && !unicode.IsNumber(char) {
Copy link
Member

Choose a reason for hiding this comment

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

De Morgan's law.


desiredMatchesActual := len(m.vmssState.Instances) == int(m.DesiredReplicas())
return !(state != nil && infrav1.IsTerminalProvisioningState(*state) && desiredMatchesActual)
return state == nil || !infrav1.IsTerminalProvisioningState(*state) || !desiredMatchesActual
Copy link
Member

Choose a reason for hiding this comment

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

De Morgan's law. Both are equivalent :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, some new linter flagged these with "De Morgan's Law."

@nawazkh
Copy link
Member

nawazkh commented Apr 17, 2025

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 8a7d0b61b4c8d646886b74cfcf8ca615b4fd14b2

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nawazkh

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 Apr 17, 2025
@k8s-ci-robot k8s-ci-robot merged commit 80398b0 into kubernetes-sigs:main Apr 17, 2025
25 of 26 checks passed
@github-project-automation github-project-automation bot moved this from Needs Review to Done in CAPZ Planning Apr 17, 2025
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Apr 17, 2025
@mboersma mboersma deleted the bump-golangci-lint branch April 17, 2025 18:30
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. 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. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants