Skip to content

Commit

Permalink
Ensure error strings not capitalised ST1005
Browse files Browse the repository at this point in the history
  • Loading branch information
e-dard committed Nov 30, 2018
1 parent 308a514 commit 9403c1e
Show file tree
Hide file tree
Showing 98 changed files with 362 additions and 384 deletions.
13 changes: 1 addition & 12 deletions bolt/bbolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ import (
"go.uber.org/zap"
)

const (
// ErrUnableToOpen means we had an issue establishing a connection (or creating the database)
ErrUnableToOpen = "Unable to open boltdb; is there a chronograf already running? %v"
// ErrUnableToBackup means we couldn't copy the db file into ./backup
ErrUnableToBackup = "Unable to backup your database prior to migrations: %v"
// ErrUnableToInitialize means we couldn't create missing Buckets (maybe a timeout)
ErrUnableToInitialize = "Unable to boot boltdb: %v"
// ErrUnableToMigrate means we had an issue changing the db schema
ErrUnableToMigrate = "Unable to migrate boltdb: %v"
)

// OpPrefix is the prefix for bolt ops
const OpPrefix = "bolt/"

Expand Down Expand Up @@ -84,7 +73,7 @@ func (c *Client) Open(ctx context.Context) error {
// Open database file.
db, err := bolt.Open(c.Path, 0600, &bolt.Options{Timeout: 1 * time.Second})
if err != nil {
return fmt.Errorf(ErrUnableToOpen, err)
return fmt.Errorf("unable to open boltdb; is there a chronograf already running? %v", err)
}
c.db = db

Expand Down
3 changes: 2 additions & 1 deletion bolt/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bolt
import (
"context"
"encoding/base64"
"errors"
"fmt"

bolt "github.com/coreos/bbolt"
Expand Down Expand Up @@ -161,7 +162,7 @@ func encodeSecretKey(orgID platform.ID, k string) ([]byte, error) {
func decodeSecretKey(key []byte) (platform.ID, string, error) {
if len(key) < platform.IDLength {
// This should not happen.
return platform.InvalidID(), "", fmt.Errorf("Provided key is too short to contain an ID. Please report this error.")
return platform.InvalidID(), "", errors.New("provided key is too short to contain an ID. Please report this error.")
}

var id platform.ID
Expand Down
8 changes: 4 additions & 4 deletions chronograf/.kapacitor/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,16 +1551,16 @@ trigger
t.Run(tt.name, func(t *testing.T) {
got, err := Reverse(tt.script)
if (err != nil) != tt.wantErr {
t.Errorf("Reverse() error = %v, wantErr %v", err, tt.wantErr)
t.Errorf("reverse error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Reverse() = %s", cmp.Diff(got, tt.want))
t.Errorf("reverse = %s", cmp.Diff(got, tt.want))
if tt.want.Query != nil {
if got.Query == nil {
t.Errorf("Reverse() = got nil QueryConfig")
t.Errorf("reverse = got nil QueryConfig")
} else if !cmp.Equal(*got.Query, *tt.want.Query) {
t.Errorf("Reverse() = QueryConfig not equal %s", cmp.Diff(*got.Query, *tt.want.Query))
t.Errorf("reverse = QueryConfig not equal %s", cmp.Diff(*got.Query, *tt.want.Query))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions chronograf/.kapacitor/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/influxdata/platform/chronograf"
client "github.com/influxdata/kapacitor/client/v1"
"github.com/influxdata/platform/chronograf"
)

type MockKapa struct {
Expand Down Expand Up @@ -424,7 +424,7 @@ func TestClient_Get(t *testing.T) {
},
taskOptions: nil,
wantErr: true,
resError: fmt.Errorf("No such task"),
resError: fmt.Errorf("no such task"),
link: client.Link{
Href: "/kapacitor/v1/tasks/myid",
},
Expand Down
4 changes: 2 additions & 2 deletions chronograf/.kapacitor/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func rangeOperators(operator string) ([]string, error) {

func chronoRangeOperators(ops []string) (string, error) {
if len(ops) != 3 {
return "", fmt.Errorf("Unknown operators")
return "", fmt.Errorf("unknown operators")
}
if ops[0] == ">=" && ops[1] == "AND" && ops[2] == "<=" {
return insideRange, nil
} else if ops[0] == "<" && ops[1] == "OR" && ops[2] == ">" {
return outsideRange, nil
}
return "", fmt.Errorf("Unknown operators")
return "", fmt.Errorf("unknown operators")
}
4 changes: 2 additions & 2 deletions chronograf/.kapacitor/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func Trigger(rule chronograf.AlertRule) (string, error) {
trigger, err = thresholdRangeTrigger(rule)
}
default:
trigger, err = "", fmt.Errorf("Unknown trigger type: %s", rule.Trigger)
trigger, err = "", fmt.Errorf("unknown trigger type: %s", rule.Trigger)
}

if err != nil {
Expand Down Expand Up @@ -137,7 +137,7 @@ func relativeTrigger(rule chronograf.AlertRule) (string, error) {
} else if rule.TriggerValues.Change == ChangeAmount {
return fmt.Sprintf(RelativeAbsoluteTrigger, op), nil
} else {
return "", fmt.Errorf("Unknown change type %s", rule.TriggerValues.Change)
return "", fmt.Errorf("unknown change type %s", rule.TriggerValues.Change)
}
}

Expand Down
6 changes: 3 additions & 3 deletions chronograf/.kapacitor/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func Vars(rule chronograf.AlertRule) (string, error) {
"0.0", // deadman threshold hardcoded to zero
), nil
default:
return "", fmt.Errorf("Unknown trigger mechanism")
return "", fmt.Errorf("unknown trigger mechanism")
}
}

Expand Down Expand Up @@ -207,7 +207,7 @@ func idVar(q *chronograf.QueryConfig) string {

func field(q *chronograf.QueryConfig) (string, error) {
if q == nil {
return "", fmt.Errorf("No fields set in query")
return "", fmt.Errorf("no fields set in query")
}
if len(q.Fields) != 1 {
return "", fmt.Errorf("expect only one field but found %d", len(q.Fields))
Expand All @@ -223,7 +223,7 @@ func field(q *chronograf.QueryConfig) (string, error) {
return f, nil
}
}
return "", fmt.Errorf("No fields set in query")
return "", fmt.Errorf("no fields set in query")
}
f, ok := field.Value.(string)
if !ok {
Expand Down
19 changes: 4 additions & 15 deletions chronograf/bolt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ import (
"github.com/influxdata/platform/chronograf/id"
)

const (
// ErrUnableToOpen means we had an issue establishing a connection (or creating the database)
ErrUnableToOpen = "Unable to open boltdb; is there a chronograf already running? %v"
// ErrUnableToBackup means we couldn't copy the db file into ./backup
ErrUnableToBackup = "Unable to backup your database prior to migrations: %v"
// ErrUnableToInitialize means we couldn't create missing Buckets (maybe a timeout)
ErrUnableToInitialize = "Unable to boot boltdb: %v"
// ErrUnableToMigrate means we had an issue changing the db schema
ErrUnableToMigrate = "Unable to migrate boltdb: %v"
)

// Client is a client for the boltDB data store.
type Client struct {
Path string
Expand Down Expand Up @@ -104,25 +93,25 @@ func (c *Client) Open(ctx context.Context, logger chronograf.Logger, build chron
// Open database file.
db, err := bolt.Open(c.Path, 0600, &bolt.Options{Timeout: 1 * time.Second})
if err != nil {
return fmt.Errorf(ErrUnableToOpen, err)
return fmt.Errorf("unable to open boltdb; is there a chronograf already running? %v", err)
}
c.db = db
c.logger = logger

for _, opt := range opts {
if opt.Backup() {
if err = c.backup(ctx, build); err != nil {
return fmt.Errorf(ErrUnableToBackup, err)
return fmt.Errorf("unable to backup your database prior to migrations: %v", err)
}
}
}
}

if err := c.initialize(ctx); err != nil {
return fmt.Errorf(ErrUnableToInitialize, err)
return fmt.Errorf("unable to boot boltdb: %v", err)
}
if err := c.migrate(ctx, build); err != nil {
return fmt.Errorf(ErrUnableToMigrate, err)
return fmt.Errorf("unable to migrate boltdb: %v", err)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions chronograf/bolt/internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func UnmarshalConfig(data []byte, c *chronograf.Config) error {
return err
}
if pb.Auth == nil {
return fmt.Errorf("Auth config is nil")
return fmt.Errorf("auth config is nil")
}
c.Auth.SuperAdminNewUsers = pb.Auth.SuperAdminNewUsers

Expand Down Expand Up @@ -791,7 +791,7 @@ func UnmarshalOrganizationConfig(data []byte, c *chronograf.OrganizationConfig)
}

if pb.LogViewer == nil {
return fmt.Errorf("Log Viewer config is nil")
return fmt.Errorf("log Viewer config is nil")
}

c.OrganizationID = pb.OrganizationID
Expand Down
6 changes: 3 additions & 3 deletions chronograf/canned/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func (s *BinLayoutsStore) All(ctx context.Context) ([]chronograf.Layout, error)

// Add is not support by BinLayoutsStore
func (s *BinLayoutsStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
return chronograf.Layout{}, fmt.Errorf("Add to BinLayoutsStore not supported")
return chronograf.Layout{}, fmt.Errorf("add to BinLayoutsStore not supported")
}

// Delete is not support by BinLayoutsStore
func (s *BinLayoutsStore) Delete(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("Delete to BinLayoutsStore not supported")
return fmt.Errorf("delete to BinLayoutsStore not supported")
}

// Get retrieves Layout if `ID` exists.
Expand Down Expand Up @@ -79,5 +79,5 @@ func (s *BinLayoutsStore) Get(ctx context.Context, ID string) (chronograf.Layout

// Update not supported
func (s *BinLayoutsStore) Update(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("Update to BinLayoutsStore not supported")
return fmt.Errorf("update to BinLayoutsStore not supported")
}
4 changes: 2 additions & 2 deletions chronograf/docs/slides/mnGo/mux/mux_go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func invalidData(w http.ResponseWriter, err error, logger chronograf.Logger) {
}

func invalidJSON(w http.ResponseWriter, logger chronograf.Logger) {
Error(w, http.StatusBadRequest, "Unparsable JSON", logger)
Error(w, http.StatusBadRequest, "unparsable JSON", logger)
}

func unknownErrorWithMessage(w http.ResponseWriter, err error, logger chronograf.Logger) {
Expand All @@ -242,7 +242,7 @@ func paramID(key string, r *http.Request) (int, error) {
param := httprouter.GetParamFromContext(ctx, key)
id, err := strconv.Atoi(param)
if err != nil {
return -1, fmt.Errorf("Error converting ID %s", param)
return -1, fmt.Errorf("error converting ID %s", param)
}
return id, nil
}
4 changes: 2 additions & 2 deletions chronograf/enterprise/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (m *MetaClient) User(ctx context.Context, name string) (*User, error) {
for _, user := range users.Users {
return &user, nil
}
return nil, fmt.Errorf("No user found")
return nil, fmt.Errorf("no user found")
}

// CreateUser adds a user to Influx Enterprise
Expand Down Expand Up @@ -279,7 +279,7 @@ func (m *MetaClient) Role(ctx context.Context, name string) (*Role, error) {
for _, role := range roles.Roles {
return &role, nil
}
return nil, fmt.Errorf("No role found")
return nil, fmt.Errorf("no role found")
}

// CreateRole adds a role to Influx Enterprise
Expand Down
4 changes: 2 additions & 2 deletions chronograf/enterprise/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,10 +1338,10 @@ func NewMockClient(code int, body []byte, headers http.Header, err error) *MockC

func (c *MockClient) Do(URL *url.URL, path, method string, authorizer influx.Authorizer, params map[string]string, body io.Reader) (*http.Response, error) {
if c == nil {
return nil, fmt.Errorf("NIL MockClient")
return nil, fmt.Errorf("nIL MockClient")
}
if URL == nil {
return nil, fmt.Errorf("NIL url")
return nil, fmt.Errorf("nIL url")
}
if c.Err != nil {
return nil, c.Err
Expand Down
4 changes: 2 additions & 2 deletions chronograf/enterprise/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func TestClient_Update(t *testing.T) {
fields: fields{
Ctrl: &mockCtrl{
changePassword: func(ctx context.Context, name, passwd string) error {
return fmt.Errorf("Ronald Reagan, the actor?! Ha Then who’s Vice President Jerry Lewis? I suppose Jane Wyman is First Lady")
return fmt.Errorf("ronald Reagan, the actor?! Ha Then who’s Vice President Jerry Lewis? I suppose Jane Wyman is First Lady")
},
},
},
Expand Down Expand Up @@ -501,7 +501,7 @@ func TestClient_Update(t *testing.T) {
fields: fields{
Ctrl: &mockCtrl{
setUserPerms: func(ctx context.Context, name string, perms enterprise.Permissions) error {
return fmt.Errorf("They found me, I don't know how, but they found me.")
return fmt.Errorf("they found me, I don't know how, but they found me.")
},
userRoles: func(ctx context.Context) (map[string]enterprise.Roles, error) {
return map[string]enterprise.Roles{}, nil
Expand Down
6 changes: 3 additions & 3 deletions chronograf/filestore/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestAll(t *testing.T) {
},
{
Existing: nil,
Err: errors.New("Error"),
Err: errors.New("error"),
},
}
for i, test := range tests {
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestAdd(t *testing.T) {
Application: "newbie",
},
ExpectedID: "",
Err: errors.New("Error"),
Err: errors.New("error"),
},
}
for i, test := range tests {
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestDelete(t *testing.T) {
Existing: nil,
DeleteID: "1",
Expected: map[string]chronograf.Layout{},
Err: errors.New("Error"),
Err: errors.New("error"),
},
}
for i, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion chronograf/filestore/kapacitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (d *Kapacitors) All(ctx context.Context) ([]chronograf.Server, error) {
}
var kapacitor chronograf.Server
if err := d.Load(path.Join(d.Dir, file.Name()), &kapacitor); err != nil {
var fmtErr = fmt.Errorf("Error loading kapacitor configuration from %v:\n%v", path.Join(d.Dir, file.Name()), err)
var fmtErr = fmt.Errorf("error loading kapacitor configuration from %v:\n%v", path.Join(d.Dir, file.Name()), err)
d.Logger.Error(fmtErr)
continue // We want to load all files we can.
} else {
Expand Down
2 changes: 1 addition & 1 deletion chronograf/filestore/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (d *Sources) All(ctx context.Context) ([]chronograf.Source, error) {
}
var source chronograf.Source
if err := d.Load(path.Join(d.Dir, file.Name()), &source); err != nil {
var fmtErr = fmt.Errorf("Error loading source configuration from %v:\n%v", path.Join(d.Dir, file.Name()), err)
var fmtErr = fmt.Errorf("error loading source configuration from %v:\n%v", path.Join(d.Dir, file.Name()), err)
d.Logger.Error(fmtErr)
continue // We want to load all files we can.
} else {
Expand Down
2 changes: 1 addition & 1 deletion chronograf/influx/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (b *BearerJWT) Set(r *http.Request) error {
if b.SharedSecret != "" && b.Username != "" {
token, err := b.Token(b.Username)
if err != nil {
return fmt.Errorf("Unable to create token")
return fmt.Errorf("unable to create token")
}
r.Header.Set("Authorization", "Bearer "+token)
}
Expand Down
2 changes: 1 addition & 1 deletion chronograf/influx/influx.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (c *Client) Users(ctx context.Context) chronograf.UsersStore {

// Roles aren't support in OSS
func (c *Client) Roles(ctx context.Context) (chronograf.RolesStore, error) {
return nil, fmt.Errorf("Roles not support in open-source InfluxDB. Roles are support in Influx Enterprise")
return nil, fmt.Errorf("roles not support in open-source InfluxDB. Roles are support in Influx Enterprise")
}

// Ping hits the influxdb ping endpoint and returns the type of influx
Expand Down
2 changes: 1 addition & 1 deletion chronograf/influx/influx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Test_Influx_AuthorizationBearer(t *testing.T) {
tokenString := strings.Split(auth, " ")[1]
token, err := gojwt.Parse(tokenString, func(token *gojwt.Token) (interface{}, error) {
if _, ok := token.Method.(*gojwt.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
}
return []byte("42"), nil
})
Expand Down
6 changes: 3 additions & 3 deletions chronograf/influx/queries/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ParseSelect(q string) (*SelectStatement, error) {
}
s, ok := stmt.(*influxql.SelectStatement)
if !ok {
return nil, fmt.Errorf("Error parsing query: not a SELECT statement")
return nil, fmt.Errorf("error parsing query: not a SELECT statement")
}
return &SelectStatement{s}, nil
}
Expand Down Expand Up @@ -252,7 +252,7 @@ func MarshalJSON(v interface{}) ([]byte, error) {
return json.Marshal(&Wildcard{v.(*influxql.Wildcard)})
default:
t := reflect.TypeOf(v)
return nil, fmt.Errorf("Error marshaling query: unknown type %s", t)
return nil, fmt.Errorf("error marshaling query: unknown type %s", t)
}
}

Expand Down Expand Up @@ -282,7 +282,7 @@ func (s *Source) MarshalJSON() ([]byte, error) {
}
return json.Marshal(m)
default:
return nil, fmt.Errorf("Error marshaling source. Subqueries not supported yet")
return nil, fmt.Errorf("error marshaling source. Subqueries not supported yet")
}
}

Expand Down
Loading

0 comments on commit 9403c1e

Please sign in to comment.