mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-03 06:08:42 +00:00
Add linter staticcheck (#535)
* Add linter staticcheck Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
116c310820
commit
fac0e16996
11 changed files with 32 additions and 17 deletions
|
@ -17,6 +17,7 @@ linters:
|
|||
- bidichk
|
||||
- misspell
|
||||
- whitespace
|
||||
- staticcheck
|
||||
|
||||
run:
|
||||
timeout: 5m
|
||||
|
|
|
@ -35,11 +35,14 @@ func logLevel(c *cli.Context) error {
|
|||
ll, err = client.SetLogLevel(&woodpecker.LogLevel{
|
||||
Level: lvl.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
ll, err = client.LogLevel()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
log.Info().Msgf("Logging level: %s", ll.Level)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
@ -352,7 +353,7 @@ func setupMetrics(g *errgroup.Group, store_ store.Store) {
|
|||
|
||||
g.Go(func() error {
|
||||
for {
|
||||
stats := server.Config.Services.Queue.Info(nil)
|
||||
stats := server.Config.Services.Queue.Info(context.TODO())
|
||||
pendingJobs.Set(float64(stats.Stats.Pending))
|
||||
waitingJobs.Set(float64(stats.Stats.WaitingOnDeps))
|
||||
runningJobs.Set(float64(stats.Stats.Running))
|
||||
|
|
|
@ -149,9 +149,9 @@ func (e *engine) Wait(ctx context.Context, proc *backend.Step) (*backend.State,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if info.State.Running {
|
||||
// todo
|
||||
}
|
||||
// if info.State.Running {
|
||||
// TODO
|
||||
// }
|
||||
|
||||
return &backend.State{
|
||||
Exited: true,
|
||||
|
|
|
@ -137,7 +137,7 @@ func (s *RPC) Update(c context.Context, id string, state rpc.State) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if proc, err = shared.UpdateProcStatus(s.store, *proc, state, build.Started); err != nil {
|
||||
if _, err = shared.UpdateProcStatus(s.store, *proc, state, build.Started); err != nil {
|
||||
log.Error().Msgf("error: rpc.update: cannot update proc: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ func New() Publisher {
|
|||
|
||||
func (p *publisher) Create(c context.Context, dest string) error {
|
||||
p.Lock()
|
||||
t, ok := p.topics[dest]
|
||||
_, ok := p.topics[dest]
|
||||
if !ok {
|
||||
t = newTopic(dest)
|
||||
t := newTopic(dest)
|
||||
p.topics[dest] = t
|
||||
}
|
||||
p.Unlock()
|
||||
|
|
|
@ -496,7 +496,9 @@ func TestWaitingVsPending(t *testing.T) {
|
|||
}
|
||||
|
||||
assert.NoError(t, q.Error(noContext, got.ID, fmt.Errorf("exitcode 1, there was an error")))
|
||||
got, _ = q.Poll(noContext, func(*Task) bool { return true })
|
||||
got, err := q.Poll(noContext, func(*Task) bool { return true })
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, task2, got)
|
||||
|
||||
info = q.Info(noContext)
|
||||
if info.Stats.WaitingOnDeps != 0 {
|
||||
|
|
|
@ -115,6 +115,9 @@ func (c *Client) FindRepo(owner string, name string) (*Repo, error) {
|
|||
log.Err(err).Msg("")
|
||||
}
|
||||
contents, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
repo := Repo{}
|
||||
err = json.Unmarshal(contents, &repo)
|
||||
if err != nil {
|
||||
|
@ -184,6 +187,9 @@ func (c *Client) CreateHook(owner string, name string, callBackLink string) erro
|
|||
|
||||
putHookSettings := arrayToHookSettings(hooks)
|
||||
hookBytes, err := json.Marshal(putHookSettings)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.doPut(fmt.Sprintf(pathHookEnabled, c.base, owner, name, hookName), hookBytes)
|
||||
}
|
||||
|
||||
|
@ -202,6 +208,9 @@ func (c *Client) DeleteHook(owner string, name string, link string) error {
|
|||
})
|
||||
putHookSettings := arrayToHookSettings(putHooks)
|
||||
hookBytes, err := json.Marshal(putHookSettings)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.doPut(fmt.Sprintf(pathHookEnabled, c.base, owner, name, hookName), hookBytes)
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ func (c *Gitea) Login(ctx context.Context, w http.ResponseWriter, req *http.Requ
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
token, err := config.Exchange(oauth2.NoContext, code)
|
||||
token, err := config.Exchange(ctx, code)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -190,9 +190,9 @@ func convertPushHook(from *webhook) *model.Build {
|
|||
if len(build.Author) == 0 {
|
||||
build.Author = from.Head.Author.Username
|
||||
}
|
||||
if len(build.Email) == 0 {
|
||||
// default to gravatar?
|
||||
}
|
||||
// if len(build.Email) == 0 {
|
||||
// TODO: default to gravatar?
|
||||
// }
|
||||
if strings.HasPrefix(build.Ref, "refs/tags/") {
|
||||
// just kidding, this is actually a tag event. Why did this come as a push
|
||||
// event we'll never know!
|
||||
|
|
|
@ -266,12 +266,11 @@ func (c *client) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model
|
|||
}
|
||||
|
||||
var files []*remote.FileMeta
|
||||
var errors []error
|
||||
|
||||
for i := 0; i < len(data); i++ {
|
||||
select {
|
||||
case err := <-errc:
|
||||
errors = append(errors, err)
|
||||
return nil, err
|
||||
case fileMeta := <-fc:
|
||||
files = append(files, fileMeta)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue