-
Notifications
You must be signed in to change notification settings - Fork 492
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
Conversation
suchen-sci
commented
Aug 28, 2023
•
edited
edited
- rm unused files, variables, consts
- rm unnecessary type assert for switch
- some are deprecated, need to update
- other unnecessary operations
Codecov ReportPatch coverage:
❗ 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
☔ View full report in Codecov by Sentry. |
4061280
to
07ad3b7
Compare
@@ -40,8 +38,6 @@ import ( | |||
|
|||
// RunServer runs Easegress server. | |||
func RunServer() { | |||
rand.Seed(time.Now().UnixNano()) | |||
|
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json
twice.