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
|
- bidichk
|
||||||
- misspell
|
- misspell
|
||||||
- whitespace
|
- whitespace
|
||||||
|
- staticcheck
|
||||||
|
|
||||||
run:
|
run:
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
|
@ -35,11 +35,14 @@ func logLevel(c *cli.Context) error {
|
||||||
ll, err = client.SetLogLevel(&woodpecker.LogLevel{
|
ll, err = client.SetLogLevel(&woodpecker.LogLevel{
|
||||||
Level: lvl.String(),
|
Level: lvl.String(),
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ll, err = client.LogLevel()
|
ll, err = client.LogLevel()
|
||||||
}
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().Msgf("Logging level: %s", ll.Level)
|
log.Info().Msgf("Logging level: %s", ll.Level)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
@ -352,7 +353,7 @@ func setupMetrics(g *errgroup.Group, store_ store.Store) {
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
for {
|
for {
|
||||||
stats := server.Config.Services.Queue.Info(nil)
|
stats := server.Config.Services.Queue.Info(context.TODO())
|
||||||
pendingJobs.Set(float64(stats.Stats.Pending))
|
pendingJobs.Set(float64(stats.Stats.Pending))
|
||||||
waitingJobs.Set(float64(stats.Stats.WaitingOnDeps))
|
waitingJobs.Set(float64(stats.Stats.WaitingOnDeps))
|
||||||
runningJobs.Set(float64(stats.Stats.Running))
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if info.State.Running {
|
// if info.State.Running {
|
||||||
// todo
|
// TODO
|
||||||
}
|
// }
|
||||||
|
|
||||||
return &backend.State{
|
return &backend.State{
|
||||||
Exited: true,
|
Exited: true,
|
||||||
|
|
|
@ -137,7 +137,7 @@ func (s *RPC) Update(c context.Context, id string, state rpc.State) error {
|
||||||
return err
|
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)
|
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 {
|
func (p *publisher) Create(c context.Context, dest string) error {
|
||||||
p.Lock()
|
p.Lock()
|
||||||
t, ok := p.topics[dest]
|
_, ok := p.topics[dest]
|
||||||
if !ok {
|
if !ok {
|
||||||
t = newTopic(dest)
|
t := newTopic(dest)
|
||||||
p.topics[dest] = t
|
p.topics[dest] = t
|
||||||
}
|
}
|
||||||
p.Unlock()
|
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")))
|
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)
|
info = q.Info(noContext)
|
||||||
if info.Stats.WaitingOnDeps != 0 {
|
if info.Stats.WaitingOnDeps != 0 {
|
||||||
|
|
|
@ -115,6 +115,9 @@ func (c *Client) FindRepo(owner string, name string) (*Repo, error) {
|
||||||
log.Err(err).Msg("")
|
log.Err(err).Msg("")
|
||||||
}
|
}
|
||||||
contents, err := ioutil.ReadAll(response.Body)
|
contents, err := ioutil.ReadAll(response.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
repo := Repo{}
|
repo := Repo{}
|
||||||
err = json.Unmarshal(contents, &repo)
|
err = json.Unmarshal(contents, &repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -184,6 +187,9 @@ func (c *Client) CreateHook(owner string, name string, callBackLink string) erro
|
||||||
|
|
||||||
putHookSettings := arrayToHookSettings(hooks)
|
putHookSettings := arrayToHookSettings(hooks)
|
||||||
hookBytes, err := json.Marshal(putHookSettings)
|
hookBytes, err := json.Marshal(putHookSettings)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return c.doPut(fmt.Sprintf(pathHookEnabled, c.base, owner, name, hookName), hookBytes)
|
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)
|
putHookSettings := arrayToHookSettings(putHooks)
|
||||||
hookBytes, err := json.Marshal(putHookSettings)
|
hookBytes, err := json.Marshal(putHookSettings)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return c.doPut(fmt.Sprintf(pathHookEnabled, c.base, owner, name, hookName), hookBytes)
|
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
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := config.Exchange(oauth2.NoContext, code)
|
token, err := config.Exchange(ctx, code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,9 +190,9 @@ func convertPushHook(from *webhook) *model.Build {
|
||||||
if len(build.Author) == 0 {
|
if len(build.Author) == 0 {
|
||||||
build.Author = from.Head.Author.Username
|
build.Author = from.Head.Author.Username
|
||||||
}
|
}
|
||||||
if len(build.Email) == 0 {
|
// if len(build.Email) == 0 {
|
||||||
// default to gravatar?
|
// TODO: default to gravatar?
|
||||||
}
|
// }
|
||||||
if strings.HasPrefix(build.Ref, "refs/tags/") {
|
if strings.HasPrefix(build.Ref, "refs/tags/") {
|
||||||
// just kidding, this is actually a tag event. Why did this come as a push
|
// just kidding, this is actually a tag event. Why did this come as a push
|
||||||
// event we'll never know!
|
// 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 files []*remote.FileMeta
|
||||||
var errors []error
|
|
||||||
|
|
||||||
for i := 0; i < len(data); i++ {
|
for i := 0; i < len(data); i++ {
|
||||||
select {
|
select {
|
||||||
case err := <-errc:
|
case err := <-errc:
|
||||||
errors = append(errors, err)
|
return nil, err
|
||||||
case fileMeta := <-fc:
|
case fileMeta := <-fc:
|
||||||
files = append(files, fileMeta)
|
files = append(files, fileMeta)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue