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

add golangci lint to github action workflow #1068

Merged
merged 15 commits into from
Aug 31, 2023

Conversation

suchen-sci
Copy link
Contributor

@suchen-sci suchen-sci commented Aug 28, 2023

  • rm unused files, variables, consts
  • rm unnecessary type assert for switch
  • some are deprecated, need to update
  • other unnecessary operations

@suchen-sci suchen-sci marked this pull request as draft August 28, 2023 07:42
@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2023

Codecov Report

Patch coverage: 62.65% and project coverage change: -0.02% ⚠️

Comparison is base (fbb4f90) 81.47% compared to head (63392b8) 81.45%.
Report is 3 commits behind head on main.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1068      +/-   ##
==========================================
- Coverage   81.47%   81.45%   -0.02%     
==========================================
  Files         136      139       +3     
  Lines       15404    15447      +43     
==========================================
+ Hits        12551    12583      +32     
- Misses       2276     2287      +11     
  Partials      577      577              
Files Changed Coverage Δ
pkg/filters/proxies/grpcproxy/pool.go 42.51% <0.00%> (-2.30%) ⬇️
pkg/filters/proxies/grpcproxy/proxy.go 89.65% <ø> (ø)
pkg/filters/validator/basicauth.go 76.35% <ø> (-0.19%) ⬇️
pkg/protocols/httpprot/response.go 83.06% <ø> (ø)
pkg/util/signer/spec.go 87.50% <ø> (ø)
pkg/util/urlclusteranalyzer/urlclusteranalyzer.go 96.10% <ø> (ø)
pkg/util/jmxtool/common.go 81.08% <80.00%> (-0.26%) ⬇️
cmd/builder/utils/context.go 100.00% <100.00%> (ø)
cmd/builder/utils/env.go 100.00% <100.00%> (ø)
cmd/builder/utils/validation.go 100.00% <100.00%> (ø)
... and 6 more

... and 1 file with indirect coverage changes

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

@@ -40,8 +38,6 @@ import (

// RunServer runs Easegress server.
func RunServer() {
rand.Seed(time.Now().UnixNano())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rand.Seed is deprecated since golang 1.20

"fmt"
"math/rand"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replace with math/rand with crypto/rand for rand.Read

supervisor := supervisor.NewMock(
nil, clusterInstance, mockMap, mockMap, nil, nil, false, nil, nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sync.Map contains lock, can't be copy.

@@ -52,8 +51,6 @@ type (
// MeshAdaptor is filter MeshAdaptor.
MeshAdaptor struct {
spec *Spec

pa *pathadaptor.PathAdaptor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not used.

@@ -293,7 +293,7 @@ func (o *OIDCAdaptor) handleOIDCCallback(ctx *context.Context) string {
return ""
}

func (o *OIDCAdaptor) fetchOIDCToken(authCode string, state string, spec *Spec, err error, rw *httpprot.Response, req *httpprot.Request) (*oidcIDToken, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this err is assigned before use in this function, so remove it.

@@ -46,10 +46,6 @@ type (
errRate5 metrics.EWMA
errRate15 metrics.EWMA

m1ErrPercent float64
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not used.

"github.com/megaease/easegress/v2/pkg/cluster"
"github.com/megaease/easegress/v2/pkg/option"
)

// NewMock return a mock supervisor for testing purpose
func NewMock(options *option.Options, cls cluster.Cluster, businessControllers sync.Map,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove sync.Map.

@@ -52,25 +52,24 @@ func JSONToKVMap(jsonStr string) (map[string]string, error) {
func extractKVs(prefix string, obj interface{}) []map[string]string {
var rst []map[string]string

switch obj.(type) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unnecessary type assertion.

@@ -68,7 +68,8 @@ func runCase(s *Semaphore, maxCount int64, t *testing.T) {
wg.Wait()

// step 2: try to acquire one more, should timeout
ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not call cancel.

@@ -50,53 +50,53 @@ type (
Literal struct {
// ScopeSuffix is the last part when build the credential scope.
// Default: megaease_request
ScopeSuffix string `json:"scopeSuffix" json:"scopeSuffix" jsonschema:"required"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

json twice.

@suchen-sci suchen-sci marked this pull request as ready for review August 29, 2023 09:04
@xxx7xxxx xxx7xxxx added this pull request to the merge queue Aug 31, 2023
Merged via the queue into easegress-io:main with commit 7a93360 Aug 31, 2023
8 checks passed
@suchen-sci suchen-sci deleted the golangci-lint branch August 31, 2023 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants