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

🌱 Bump golangci-lint, remove staticcheck #3208

Merged
merged 9 commits into from
Dec 11, 2024

Conversation

xrstf
Copy link
Contributor

@xrstf xrstf commented Dec 6, 2024

Summary

This is some housekeeping for our linters.

  • Originally, the idea behind running staticcheck standalone was that "golangci-lint should find deprecation, but it doesn't work" (in Introduce staticcheck linter for deprecations #1798). I checked and could not immediately see deprecated code that golangci-lint doesn't find by itself.

  • Additionally, Introduce staticcheck linter for deprecations #1798 doesn't even enable the necessary check in staticcheck. Instead we configured:

    • ST1019 - duplicate import statements
    • ST1005 - error strings should not be capitalized

    Both of these things can be accomplished using revive. However we have to lower the minimum confidence level from 0.8 to 0.6 to surface these issues correctly. staticcheck (the standalone binary) has some additional smarts and produces fewer false positives because it recognizes code identifiers in error strings. However a few //nolint comments are to me an acceptable downside, compared to keeping a dedicated linter around.

  • A whole bunch of functions in our SDK implicitly do a fmt.Sprintf(), which newer golangci-lint versions are complaining about if non-constant format strings are used. I pondered multiple solutions, but ultimately chose the simplest one that doesn't cause an API break (by calling MarkFalse(reason) now as MarkFalse("%s", reason)). Other options would be possible, like introducing new functions (MarkFalse and MarkFalsef) or removing the sprintf functionality alltogether, however since it's part of the SDK package, I feared an API break.

Release Notes

Update golangci-lint to 1.26.2, remove dependency on standalone staticcheck binary

xrstf added 9 commits December 6, 2024 17:43
On-behalf-of: @SAP christoph.mewes@sap.com
On-behalf-of: @SAP christoph.mewes@sap.com
On-behalf-of: @SAP christoph.mewes@sap.com
On-behalf-of: @SAP christoph.mewes@sap.com
On-behalf-of: @SAP christoph.mewes@sap.com
On-behalf-of: @SAP christoph.mewes@sap.com
On-behalf-of: @SAP christoph.mewes@sap.com
On-behalf-of: @SAP christoph.mewes@sap.com
@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 6, 2024
@xrstf xrstf requested a review from sttts December 6, 2024 17:48
@@ -162,8 +162,6 @@ func TestServiceAccounts(t *testing.T) {
}},
}
for i, ttc := range testCases {
i := i
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember reading some go release notes but cant find any about this. We don't need this anymore, right? Or what is the reasons to removing these?

Copy link
Contributor

Choose a reason for hiding this comment

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

its a closure thing with variables... Still confused why we removing this?

Copy link
Contributor Author

@xrstf xrstf Dec 7, 2024

Choose a reason for hiding this comment

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

Loop variables are copies since Go 1.22, so creating scoped copies is not necessary anymore.

See also https://go.dev/blog/go1.22#language-changes

This is what the new copyloopvar linter detects.

Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

Leaving final approval to @mjudeikis.

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 10, 2024
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 839fb75d377d658c015a8b0c13b7e04752de89e0

@mjudeikis
Copy link
Contributor

/approve
/lgtm

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjudeikis

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

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 11, 2024
@kcp-ci-bot kcp-ci-bot merged commit 5dd5df4 into kcp-dev:main Dec 11, 2024
17 checks passed
@xrstf xrstf deleted the bump-golangci-lint branch December 13, 2024 16:28
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. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

4 participants