Skip to content

bump golangci-lint to v2.0.2 #225

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

warjiang
Copy link
Contributor

@warjiang warjiang commented Jul 8, 2025

What type of PR is this?

  • upgrade golang lint version to v1.64.2
  • disable package-comments in revive
  • add excluded dir for futher lifting cod

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 8, 2025
@karmada-bot karmada-bot requested review from jhnine and samzong July 8, 2025 06:49
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from warjiang. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@warjiang
Copy link
Contributor Author

warjiang commented Jul 8, 2025

/assign @RainbowMango @samzong

@karmada-bot karmada-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 8, 2025
@RainbowMango RainbowMango added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 8, 2025
@@ -19,7 +19,7 @@ set -o nounset
set -o pipefail

REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
GOLANGCI_LINT_VER="v1.59.0"
GOLANGCI_LINT_VER="v1.64.2"
Copy link
Member

Choose a reason for hiding this comment

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

Shall we bump it to v2.0.2? consistent with [email protected] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1, I appreciate to upgrade golangci-lint

@@ -123,7 +123,7 @@ func serve(opts *options.Options) {
r.NoRoute(func(c *gin.Context) {
indexHTML := "no content"
indexPath := path.Join(opts.StaticDir, "index.html")
f, err := os.Open(indexPath)
f, err := os.Open(indexPath) // #nosec
Copy link
Member

Choose a reason for hiding this comment

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

It would be great if we can explain the false-positive warnings, like:
https://github.com/karmada-io/karmada/blob/d231a87aed73252a915a80edf48d96030036cb86/pkg/estimator/client/general.go#L69

Same as below.

.golangci.yml Outdated
@@ -58,6 +58,7 @@ linters-settings:
- name: if-return
disabled: true
- name: package-comments
disabled: true
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because I don't want to add package comments 😢 , currently, I accept the suggestion and prepare to enable the rule

.golangci.yml Outdated
Comment on lines 107 to 109
- (^|/)cmd/kubernetes-dashboard-api($|/)
- (^|/)pkg/kubernetes-dashboard-common($|/)
- (^|/)cmd/metrics-scraper($|/)
Copy link
Member

Choose a reason for hiding this comment

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

Just a question, why should these directories be excluded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for further lift code from kubernetes dashboard api, I split the changes into two PRs

@@ -123,7 +123,7 @@ func serve(opts *options.Options) {
r.NoRoute(func(c *gin.Context) {
indexHTML := "no content"
indexPath := path.Join(opts.StaticDir, "index.html")
f, err := os.Open(indexPath)
f, err := os.Open(indexPath) // #nosec
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
f, err := os.Open(indexPath) // #nosec
if err := validatePath(indexPath); err != nil {
return err
}
f, err := os.Open(indexPath)

.golangci.yml Outdated
@@ -58,6 +58,7 @@ linters-settings:
- name: if-return
disabled: true
- name: package-comments
disabled: true
Copy link
Member

Choose a reason for hiding this comment

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

I suggest not.

violates Go standards, It's should fix issues, not suppress.

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 suggest not.

violates Go standards, It's should fix issues, not suppress.

agree with your advice, so I decide to enable package-comments rule

@RainbowMango
Copy link
Member

/retitle bump golangci-lint to v2.0.2

@karmada-bot karmada-bot changed the title ci(lint): upgrade lint version & modify lint rules bump golangci-lint to v2.0.2 Jul 9, 2025
@karmada-bot karmada-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants