karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.12k stars 807 forks source link

provide a tips to fix golangci-lint error #4636

Closed zhzhuang-zju closed 2 weeks ago

zhzhuang-zju commented 2 months ago

What type of PR is this? /kind cleanup

What this PR does / why we need it: Many times, facing golangci-lint errors, such as File is not `gci`-ed with --skip-generated -s Standard -s Default -s Prefix, do not know its meaning, and therefore do not know the specific modification method. At this time, we can automatically fix it through command golangci-lint run --fix, and we can understand the reason for the error by viewing the modification points through git diff. Which issue(s) this PR fixes: Fixes #

Special notes for your reviewer: Take #4622 for example,

(base) ➜  karmada git:(revive) ✗ hack/verify-staticcheck.sh 
Using golangci-lint version:
golangci-lint has version 1.52.2 built with go1.20.2 from da04413a on 2023-03-25T18:11:28Z
test/e2e/lazy_activation_policy_test.go:20: File is not `gci`-ed with --skip-generated -s Standard,Default,Prefix(github.com/karmada-io/karmada) (gci)
        policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
        "github.com/karmada-io/karmada/test/e2e/framework"
        testhelper "github.com/karmada-io/karmada/test/helper"
test/e2e/lazy_activation_policy_test.go:25: File is not `gci`-ed with --skip-generated -s Standard,Default,Prefix(github.com/karmada-io/karmada) (gci)
        "k8s.io/apimachinery/pkg/util/rand"

Please review the above warnings.
If the above warnings make sense, run "golangci-lint run --fix" to auto fix it
If the above warnings do not make sense, feel free to file an issue.

(base) ➜  karmada git:(revive) ✗ golangci-lint run --fix
(base) ➜  karmada git:(revive) ✗ git diff test/e2e/lazy_activation_policy_test.go
diff --git a/test/e2e/lazy_activation_policy_test.go b/test/e2e/lazy_activation_policy_test.go
index bc57439c0..185095a67 100644
--- a/test/e2e/lazy_activation_policy_test.go
+++ b/test/e2e/lazy_activation_policy_test.go
@@ -17,12 +17,13 @@ limitations under the License.
 package e2e

 import (
-       policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
-       "github.com/karmada-io/karmada/test/e2e/framework"
-       testhelper "github.com/karmada-io/karmada/test/helper"
        "github.com/onsi/ginkgo/v2"
        appsv1 "k8s.io/api/apps/v1"
        "k8s.io/apimachinery/pkg/util/rand"
+
+       policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
+       "github.com/karmada-io/karmada/test/e2e/framework"
+       testhelper "github.com/karmada-io/karmada/test/helper"
 )

Does this PR introduce a user-facing change?:

NONE
codecov-commenter commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (f03b5e9) 51.55% compared to head (5f40e23) 51.56%. Report is 2 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #4636 +/- ## ======================================= Coverage 51.55% 51.56% ======================================= Files 250 250 Lines 24904 24904 ======================================= + Hits 12839 12841 +2 + Misses 11358 11357 -1 + Partials 707 706 -1 ``` | [Flag](https://app.codecov.io/gh/karmada-io/karmada/pull/4636/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=karmada-io) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/karmada-io/karmada/pull/4636/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=karmada-io) | `51.56% <ø> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=karmada-io#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

karmada-bot commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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: - ~~[hack/OWNERS](https://github.com/karmada-io/karmada/blob/master/hack/OWNERS)~~ [RainbowMango] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment