Add golangci-lint workflow (#4999)

* fix lint workflow

* add golang lint

* close http response body
This commit is contained in:
andrew_li
2022-06-29 11:58:36 +08:00
committed by GitHub
parent f1e06466df
commit f289795312
141 changed files with 311 additions and 592 deletions

View File

@@ -210,6 +210,7 @@ func (d devopsOperator) ListDevOpsProject(workspace string, limit, offset int) (
if err != nil {
return api.ListResult{}, nil
}
//nolint:staticcheck,ineffassign
items := make([]interface{}, 0)
var result []interface{}
for _, item := range data {
@@ -550,7 +551,7 @@ func (d devopsOperator) GetNodesDetail(projectName, pipelineName, runId string,
return nil, err
}
Nodes, err := json.Marshal(respNodes)
Nodes, _ := json.Marshal(respNodes)
err = json.Unmarshal(Nodes, &nodesDetails)
if err != nil {
klog.Error(err)
@@ -722,7 +723,7 @@ func (d devopsOperator) GetBranchNodesDetail(projectName, pipelineName, branchNa
klog.Error(err)
return nil, err
}
Nodes, err := json.Marshal(respNodes)
Nodes, _ := json.Marshal(respNodes)
err = json.Unmarshal(Nodes, &nodesDetails)
if err != nil {
klog.Error(err)
@@ -982,9 +983,9 @@ func getInputReqBody(reqBody io.ReadCloser) (newReqBody io.ReadCloser, err error
return nil, err
}
err = json.Unmarshal(Body, &checkBody)
json.Unmarshal(Body, &checkBody)
if checkBody.Abort != true && checkBody.Parameters == nil {
if !checkBody.Abort && checkBody.Parameters == nil {
workRound.Parameters = []devops.CheckPlayloadParameters{}
workRound.ID = checkBody.ID
jsonBody, _ = json.Marshal(workRound)

View File

@@ -39,7 +39,6 @@ import (
const (
fileaContents = "This is a test file."
fileaKey = "binary"
fileaName = "filea.txt"
boundary = `MyBoundary`
ns = "testns"
@@ -63,6 +62,7 @@ func TestS2iBinaryUploader(t *testing.T) {
informerFactory := ksinformers.NewSharedInformerFactory(fakeKubeClient, 0)
stopCh := make(chan struct{})
s2iInformer := informerFactory.Devops().V1alpha1().S2iBinaries()
//nolint:ineffassign,staticcheck
err := s2iInformer.Informer().GetIndexer().Add(s2ib)
defer close(stopCh)
informerFactory.Start(stopCh)