Merge PR #5055: Added Prealloc, Gosec, Golint linters

This commit is contained in:
Marko
2019-09-17 12:13:26 -04:00
committed by Alexander Bezobchuk
parent 943cc54811
commit 936cffef40
13 changed files with 36 additions and 30 deletions
+5 -5
View File
@@ -153,23 +153,23 @@ func (e Error) Codespace() string {
// Is check if given error instance is of a given kind/type. This involves
// unwrapping given error using the Cause method if available.
func (kind *Error) Is(err error) bool {
func (e *Error) Is(err error) bool {
// Reflect usage is necessary to correctly compare with
// a nil implementation of an error.
if kind == nil {
if e == nil {
return isNilErr(err)
}
for {
if err == kind {
if err == e {
return true
}
// If this is a collection of errors, this function must return
// true if at least one from the group match.
if u, ok := err.(unpacker); ok {
for _, e := range u.Unpack() {
if kind.Is(e) {
for _, er := range u.Unpack() {
if e.Is(er) {
return true
}
}
+3 -6
View File
@@ -174,11 +174,8 @@ func (se StringEvents) Flatten() StringEvents {
for _, e := range se {
flatEvents[e.Type] = append(flatEvents[e.Type], e.Attributes...)
}
var (
res StringEvents
keys []string
)
keys := make([]string, 0, len(flatEvents))
res := make(StringEvents, 0, len(flatEvents)) // appeneded to keys, same length of what is allocated to keys
for ty := range flatEvents {
keys = append(keys, ty)
@@ -209,7 +206,7 @@ func StringifyEvent(e abci.Event) StringEvent {
// StringifyEvents converts a slice of Event objects into a slice of StringEvent
// objects.
func StringifyEvents(events []abci.Event) StringEvents {
var res StringEvents
res := make(StringEvents, 0, len(events))
for _, e := range events {
res = append(res, StringifyEvent(e))
+1 -1
View File
@@ -201,7 +201,7 @@ type Manager struct {
func NewManager(modules ...AppModule) *Manager {
moduleMap := make(map[string]AppModule)
var modulesStr []string
modulesStr := make([]string, 0, len(modules))
for _, module := range modules {
moduleMap[module.Name()] = module
modulesStr = append(modulesStr, module.Name())