From 116c310820548e89c01f507775abb1ac2b91c8fe Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 24 Nov 2021 02:01:12 +0100 Subject: [PATCH] Add linter misspell (#530) * Add linter misspell * Fix spelling Co-authored-by: Anbraten --- .golangci.yml | 3 +++ agent/runner.go | 6 +++--- cmd/agent/signal.go | 2 +- cmd/server/server.go | 6 +++--- pipeline/error.go | 2 +- pipeline/frontend/yaml/container.go | 2 +- pipeline/frontend/yaml/network.go | 2 +- pipeline/frontend/yaml/secret.go | 2 +- pipeline/frontend/yaml/types/types_yaml.go | 10 +++++----- pipeline/frontend/yaml/types/ulimit.go | 2 +- pipeline/frontend/yaml/types/volume.go | 2 +- pipeline/frontend/yaml/volume.go | 2 +- pipeline/interrupt/interrupt.go | 2 +- pipeline/rpc/peer.go | 3 --- server/api/build.go | 2 +- server/model/event.go | 8 ++++---- server/queue/fifo_test.go | 8 ++++---- server/queue/queue.go | 4 ++-- server/swagger/files/swagger.yml | 2 +- 19 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7375d708b..7265572ed 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,8 @@ linters-settings: gofmt: simplify: true + misspell: + locale: US linters: disable-all: true @@ -13,6 +15,7 @@ linters: - typecheck - errcheck - bidichk + - misspell - whitespace run: diff --git a/agent/runner.go b/agent/runner.go index 9b1d1523a..72a1f7086 100644 --- a/agent/runner.go +++ b/agent/runner.go @@ -98,12 +98,12 @@ func (r *Runner) Run(ctx context.Context) error { ctx, cancel := context.WithTimeout(ctxmeta, timeout) defer cancel() - cancelled := abool.New() + canceled := abool.New() go func() { logger.Debug().Msg("listen for cancel signal") if werr := r.client.Wait(ctx, work.ID); werr != nil { - cancelled.SetTo(true) + canceled.SetTo(true) logger.Warn().Err(werr).Msg("cancel signal received") cancel() @@ -311,7 +311,7 @@ func (r *Runner) Run(ctx context.Context) error { state.ExitCode = 1 state.Error = err.Error() } - if cancelled.IsSet() { + if canceled.IsSet() { state.ExitCode = 137 } } diff --git a/cmd/agent/signal.go b/cmd/agent/signal.go index e68917d6d..cec55529b 100644 --- a/cmd/agent/signal.go +++ b/cmd/agent/signal.go @@ -12,7 +12,7 @@ import ( "syscall" ) -// WithContextFunc returns a copy of parent context that is cancelled when +// WithContextFunc returns a copy of parent context that is canceled when // an os interrupt signal is received. The callback function f is invoked // before cancellation. func WithContextFunc(ctx context.Context, f func()) context.Context { diff --git a/cmd/server/server.go b/cmd/server/server.go index 3bccc47cc..02735c991 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -155,12 +155,12 @@ func run(c *cli.Context) error { log.Err(err).Msg("") return err } - auther := &authorizer{ + authorizer := &authorizer{ password: c.String("agent-secret"), } grpcServer := grpc.NewServer( - grpc.StreamInterceptor(auther.streamInterceptor), - grpc.UnaryInterceptor(auther.unaryIntercaptor), + grpc.StreamInterceptor(authorizer.streamInterceptor), + grpc.UnaryInterceptor(authorizer.unaryIntercaptor), grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ MinTime: c.Duration("keepalive-min-time"), }), diff --git a/pipeline/error.go b/pipeline/error.go index bee2ac029..fb251e0db 100644 --- a/pipeline/error.go +++ b/pipeline/error.go @@ -12,7 +12,7 @@ var ( // ErrCancel is used as a return value when the container execution receives // a cancellation signal from the context. - ErrCancel = errors.New("Cancelled") + ErrCancel = errors.New("Canceled") ) // An ExitError reports an unsuccessful exit. diff --git a/pipeline/frontend/yaml/container.go b/pipeline/frontend/yaml/container.go index e72339f34..3172d97f4 100644 --- a/pipeline/frontend/yaml/container.go +++ b/pipeline/frontend/yaml/container.go @@ -62,7 +62,7 @@ type ( } ) -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (c *Containers) UnmarshalYAML(value *yaml.Node) error { containers := map[string]Container{} err := value.Decode(&containers) diff --git a/pipeline/frontend/yaml/network.go b/pipeline/frontend/yaml/network.go index 5e10c96fa..29cb6e1e7 100644 --- a/pipeline/frontend/yaml/network.go +++ b/pipeline/frontend/yaml/network.go @@ -20,7 +20,7 @@ type ( } ) -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (n *Networks) UnmarshalYAML(value *yaml.Node) error { networks := map[string]Network{} err := value.Decode(&networks) diff --git a/pipeline/frontend/yaml/secret.go b/pipeline/frontend/yaml/secret.go index 07e9dba92..cc254e673 100644 --- a/pipeline/frontend/yaml/secret.go +++ b/pipeline/frontend/yaml/secret.go @@ -15,7 +15,7 @@ type ( } ) -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (s *Secrets) UnmarshalYAML(value *yaml.Node) error { y, _ := yaml.Marshal(value) diff --git a/pipeline/frontend/yaml/types/types_yaml.go b/pipeline/frontend/yaml/types/types_yaml.go index 24504ecbd..8a36474af 100644 --- a/pipeline/frontend/yaml/types/types_yaml.go +++ b/pipeline/frontend/yaml/types/types_yaml.go @@ -13,7 +13,7 @@ import ( // StringorInt represents a string or an integer. type StringorInt int64 -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (s *StringorInt) UnmarshalYAML(unmarshal func(interface{}) error) error { var intType int64 if err := unmarshal(&intType); err == nil { @@ -39,7 +39,7 @@ func (s *StringorInt) UnmarshalYAML(unmarshal func(interface{}) error) error { // the String supports notations like 10m for then Megabyte of memory type MemStringorInt int64 -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (s *MemStringorInt) UnmarshalYAML(unmarshal func(interface{}) error) error { var intType int64 if err := unmarshal(&intType); err == nil { @@ -62,10 +62,10 @@ func (s *MemStringorInt) UnmarshalYAML(unmarshal func(interface{}) error) error } // Stringorslice represents -// Using engine-api Strslice and augment it with YAML marshalling stuff. a string or an array of strings. +// Using engine-api Strslice and augment it with YAML marshaling stuff. a string or an array of strings. type Stringorslice strslice.StrSlice -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (s *Stringorslice) UnmarshalYAML(unmarshal func(interface{}) error) error { var stringType string if err := unmarshal(&stringType); err == nil { @@ -89,7 +89,7 @@ func (s *Stringorslice) UnmarshalYAML(unmarshal func(interface{}) error) error { // SliceorMap represents a slice or a map of strings. type SliceorMap map[string]string -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (s *SliceorMap) UnmarshalYAML(unmarshal func(interface{}) error) error { var sliceType []interface{} if err := unmarshal(&sliceType); err == nil { diff --git a/pipeline/frontend/yaml/types/ulimit.go b/pipeline/frontend/yaml/types/ulimit.go index 9981cc295..b7025537e 100644 --- a/pipeline/frontend/yaml/types/ulimit.go +++ b/pipeline/frontend/yaml/types/ulimit.go @@ -21,7 +21,7 @@ func (u Ulimits) MarshalYAML() (interface{}, error) { return ulimitMap, nil } -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (u *Ulimits) UnmarshalYAML(unmarshal func(interface{}) error) error { ulimits := make(map[string]Ulimit) diff --git a/pipeline/frontend/yaml/types/volume.go b/pipeline/frontend/yaml/types/volume.go index 3dad7b364..3586e334d 100644 --- a/pipeline/frontend/yaml/types/volume.go +++ b/pipeline/frontend/yaml/types/volume.go @@ -42,7 +42,7 @@ func (v Volumes) MarshalYAML() (interface{}, error) { return vs, nil } -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (v *Volumes) UnmarshalYAML(unmarshal func(interface{}) error) error { var sliceType []interface{} if err := unmarshal(&sliceType); err == nil { diff --git a/pipeline/frontend/yaml/volume.go b/pipeline/frontend/yaml/volume.go index b4b1b1ab7..a0fdeff58 100644 --- a/pipeline/frontend/yaml/volume.go +++ b/pipeline/frontend/yaml/volume.go @@ -20,7 +20,7 @@ type ( } ) -// UnmarshalYAML implements the Unmarshaller interface. +// UnmarshalYAML implements the Unmarshaler interface. func (v *Volumes) UnmarshalYAML(value *yaml.Node) error { y, _ := yaml.Marshal(value) diff --git a/pipeline/interrupt/interrupt.go b/pipeline/interrupt/interrupt.go index adf79b6f1..477db8dc7 100644 --- a/pipeline/interrupt/interrupt.go +++ b/pipeline/interrupt/interrupt.go @@ -14,7 +14,7 @@ func WithContext(ctx context.Context) context.Context { }) } -// WithContextFunc returns a copy of parent context that is cancelled when +// WithContextFunc returns a copy of parent context that is canceled when // an os interrupt signal is received. The callback function f is invoked // before cancellation. func WithContextFunc(ctx context.Context, f func()) context.Context { diff --git a/pipeline/rpc/peer.go b/pipeline/rpc/peer.go index afbd9299e..c274a3aea 100644 --- a/pipeline/rpc/peer.go +++ b/pipeline/rpc/peer.go @@ -6,9 +6,6 @@ import ( "github.com/woodpecker-ci/woodpecker/pipeline/backend" ) -// ErrCancelled signals the pipeline is cancelled. -// var ErrCancelled = errors.New("cancelled") - type ( // Filter defines filters for fetching items from the queue. Filter struct { diff --git a/server/api/build.go b/server/api/build.go index 96c8bc536..44f9f4ea9 100644 --- a/server/api/build.go +++ b/server/api/build.go @@ -251,7 +251,7 @@ func DeleteBuild(c *gin.Context) { return } killedBuild.Procs = model.Tree(procs) - if err := publishToTopic(c, killedBuild, repo, model.Cancelled); err != nil { + if err := publishToTopic(c, killedBuild, repo, model.Canceled); err != nil { log.Error().Err(err).Msg("publishToTopic") } } diff --git a/server/model/event.go b/server/model/event.go index a230a8800..dca090f76 100644 --- a/server/model/event.go +++ b/server/model/event.go @@ -18,10 +18,10 @@ package model type EventType string const ( - Enqueued EventType = "enqueued" - Started EventType = "started" - Finished EventType = "finished" - Cancelled EventType = "cancelled" + Enqueued EventType = "enqueued" + Started EventType = "started" + Finished EventType = "finished" + Canceled EventType = "canceled" ) // Event represents a build event. diff --git a/server/queue/fifo_test.go b/server/queue/fifo_test.go index f277d147b..16004877b 100644 --- a/server/queue/fifo_test.go +++ b/server/queue/fifo_test.go @@ -411,13 +411,13 @@ func TestFifoCancel(t *testing.T) { assert.NoError(t, q.PushAtOnce(noContext, []*Task{task2, task3, task1})) _, _ = q.Poll(noContext, func(*Task) bool { return true }) - assert.NoError(t, q.Error(noContext, task1.ID, fmt.Errorf("cancelled"))) - assert.NoError(t, q.Error(noContext, task2.ID, fmt.Errorf("cancelled"))) - assert.NoError(t, q.Error(noContext, task3.ID, fmt.Errorf("cancelled"))) + assert.NoError(t, q.Error(noContext, task1.ID, fmt.Errorf("canceled"))) + assert.NoError(t, q.Error(noContext, task2.ID, fmt.Errorf("canceled"))) + assert.NoError(t, q.Error(noContext, task3.ID, fmt.Errorf("canceled"))) info := q.Info(noContext) if len(info.Pending) != 0 { - t.Errorf("All pipelines should be cancelled") + t.Errorf("All pipelines should be canceled") return } } diff --git a/server/queue/queue.go b/server/queue/queue.go index afb557278..fb998041c 100644 --- a/server/queue/queue.go +++ b/server/queue/queue.go @@ -10,8 +10,8 @@ import ( ) var ( - // ErrCancel indicates the task was cancelled. - ErrCancel = errors.New("queue: task cancelled") + // ErrCancel indicates the task was canceled. + ErrCancel = errors.New("queue: task canceled") // ErrNotFound indicates the task was not found in the queue. ErrNotFound = errors.New("queue: task not found") diff --git a/server/swagger/files/swagger.yml b/server/swagger/files/swagger.yml index 7005b7a93..389414b78 100644 --- a/server/swagger/files/swagger.yml +++ b/server/swagger/files/swagger.yml @@ -377,7 +377,7 @@ paths: - accessToken: [] responses: 200: - description: Successfully cancelled the Job + description: Successfully canceled the Job 404: description: | Unable to find the Repository or Job