From 27702a0f2bfa175ec808b8efaa767b8c2eb5f281 Mon Sep 17 00:00:00 2001 From: Nathaniel Caza Date: Mon, 2 Dec 2019 10:38:45 -0600 Subject: [PATCH] go: linting fixes (#242) * run gofmt with -s * fix spelling mistakes --- auth/handler.go | 2 +- devtools/ci/tasks/scripts/codecheck.sh | 2 +- devtools/mockslack/state.go | 2 +- devtools/runjson/task.go | 2 +- engine/engine.go | 6 +++--- engine/message/config.go | 4 ++-- engine/message/queue.go | 2 +- oncall/state_test.go | 12 ++++++------ 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/auth/handler.go b/auth/handler.go index 652ecbf99e..61997783d1 100644 --- a/auth/handler.go +++ b/auth/handler.go @@ -155,7 +155,7 @@ func (h *Handler) ServeProviders(w http.ResponseWriter, req *http.Request) { // IdentityProviderHandler will return a handler for the given provider ID. // -// It panics if the id has not been registerd with AddIdentityProvider. +// It panics if the id has not been registered with AddIdentityProvider. func (h *Handler) IdentityProviderHandler(id string) http.HandlerFunc { p, ok := h.providers[id] if !ok { diff --git a/devtools/ci/tasks/scripts/codecheck.sh b/devtools/ci/tasks/scripts/codecheck.sh index deef19bd20..4bfb0eaec8 100755 --- a/devtools/ci/tasks/scripts/codecheck.sh +++ b/devtools/ci/tasks/scripts/codecheck.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -NOFMT=$(gofmt -l $(find . -name '*.go' |grep -v /vendor)) +NOFMT=$(gofmt -s -l $(find . -name '*.go' |grep -v /vendor)) if test "$NOFMT" != "" then diff --git a/devtools/mockslack/state.go b/devtools/mockslack/state.go index 04ff770d38..8d47c72bac 100644 --- a/devtools/mockslack/state.go +++ b/devtools/mockslack/state.go @@ -56,7 +56,7 @@ type channelState struct { } // SetAutoCreateChannel, if set to true, will cause messages sent to -// non-existant channels to succeed by creating the channel automatically. +// non-existent channels to succeed by creating the channel automatically. func (st *state) SetAutoCreateChannel(value bool) { st.mx.Lock() defer st.mx.Unlock() diff --git a/devtools/runjson/task.go b/devtools/runjson/task.go index a1f5eae8cd..66b4a2ad22 100644 --- a/devtools/runjson/task.go +++ b/devtools/runjson/task.go @@ -18,7 +18,7 @@ import ( "github.com/pkg/errors" ) -// A Task is an independant unit of work +// A Task is an independent unit of work type Task struct { // Name is used to identify the task in the case of errors, as well as the prefix for logs. Name string diff --git a/engine/engine.go b/engine/engine.go index 2e1786c799..f272d5a7de 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -137,9 +137,9 @@ func NewEngine(ctx context.Context, db *sql.DB, c *Config) (*Engine, error) { p.msg, err = message.NewDB(ctx, db, &message.Config{ MaxMessagesPerCycle: c.MaxMessages, RateLimit: map[notification.DestType]*message.RateConfig{ - notification.DestTypeSMS: &message.RateConfig{PerSecond: 1, Batch: 5 * time.Second}, - notification.DestTypeVoice: &message.RateConfig{PerSecond: 1, Batch: 5 * time.Second}, - notification.DestTypeSlackChannel: &message.RateConfig{PerSecond: 5, Batch: 5 * time.Second}, + notification.DestTypeSMS: {PerSecond: 1, Batch: 5 * time.Second}, + notification.DestTypeVoice: {PerSecond: 1, Batch: 5 * time.Second}, + notification.DestTypeSlackChannel: {PerSecond: 5, Batch: 5 * time.Second}, }, Pausable: p.mgr, }) diff --git a/engine/message/config.go b/engine/message/config.go index 3c19d85650..cc3147dc2e 100644 --- a/engine/message/config.go +++ b/engine/message/config.go @@ -36,11 +36,11 @@ type Config struct { func DefaultConfig() *Config { return &Config{ RateLimit: map[notification.DestType]*RateConfig{ - notification.DestTypeSMS: &RateConfig{ + notification.DestTypeSMS: { PerSecond: 1, Batch: 5 * time.Second, }, - notification.DestTypeVoice: &RateConfig{ + notification.DestTypeVoice: { PerSecond: 1, Batch: 5 * time.Second, }, diff --git a/engine/message/queue.go b/engine/message/queue.go index 89df388f1d..4aec004697 100644 --- a/engine/message/queue.go +++ b/engine/message/queue.go @@ -90,7 +90,7 @@ func (q *queue) servicePriority(serviceA, serviceB string) (isLess, ok bool) { sentB := q.serviceSent[serviceB] if sentA.Equal(sentB) { - // neither has recieved a message + // neither has received a message return false, false } diff --git a/oncall/state_test.go b/oncall/state_test.go index fe6091ba74..50e4b963e6 100644 --- a/oncall/state_test.go +++ b/oncall/state_test.go @@ -93,19 +93,19 @@ func BenchmarkState_CalculateShifts(b *testing.B) { }, }, overrides: []override.UserOverride{ - override.UserOverride{ + { AddUserID: "binbaz", RemoveUserID: "foobar", Start: time.Date(2018, 1, 1, 8, 30, 0, 0, time.UTC), End: time.Date(2018, 1, 1, 8, 45, 0, 0, time.UTC), }, - override.UserOverride{ + { AddUserID: "binbaz2", RemoveUserID: "foobar", Start: time.Date(2018, 1, 1, 8, 30, 0, 0, time.UTC), End: time.Date(2018, 1, 1, 8, 45, 0, 0, time.UTC), }, - override.UserOverride{ + { AddUserID: "binbaz", RemoveUserID: "foob3ar", Start: time.Date(2018, 1, 1, 8, 30, 0, 0, time.UTC), @@ -287,7 +287,7 @@ func TestState_CalculateShifts(t *testing.T) { }}, }, overrides: []override.UserOverride{ - override.UserOverride{ + { AddUserID: "binbaz", RemoveUserID: "foobar", Start: time.Date(2018, 1, 1, 8, 30, 0, 0, time.UTC), @@ -331,7 +331,7 @@ func TestState_CalculateShifts(t *testing.T) { }}, }, overrides: []override.UserOverride{ - override.UserOverride{ + { AddUserID: "binbaz", Start: time.Date(2018, 1, 1, 8, 30, 0, 0, time.UTC), End: time.Date(2018, 1, 1, 8, 45, 0, 0, time.UTC), @@ -368,7 +368,7 @@ func TestState_CalculateShifts(t *testing.T) { }}, }, overrides: []override.UserOverride{ - override.UserOverride{ + { RemoveUserID: "foobar", Start: time.Date(2018, 1, 1, 8, 30, 0, 0, time.UTC), End: time.Date(2018, 1, 1, 8, 45, 0, 0, time.UTC),