From 1a7c6b7007e9721e3f2e97c081990e68f2218564 Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Sat, 15 Sep 2018 00:37:49 +0300 Subject: [PATCH] realize: don't guard against negative length len never returns negative value, so guarding against it is confusing and misleading. --- realize.go | 2 +- realize/cli_test.go | 2 +- realize/projects.go | 2 +- realize_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/realize.go b/realize.go index ff96bba..93968b3 100644 --- a/realize.go +++ b/realize.go @@ -1144,7 +1144,7 @@ func start(c *cli.Context) (err error) { } // check project list length - if len(r.Schema.Projects) <= 0 { + if len(r.Schema.Projects) == 0 { // create a new project based on given params project := r.Schema.New(c) // Add to projects list diff --git a/realize/cli_test.go b/realize/cli_test.go index 852eaa2..58ecfe9 100644 --- a/realize/cli_test.go +++ b/realize/cli_test.go @@ -44,7 +44,7 @@ func TestRealize_Prefix(t *testing.T) { r := Realize{} input := "test" result := r.Prefix(input) - if len(result) <= 0 && !strings.Contains(result, input) { + if len(result) == 0 && !strings.Contains(result, input) { t.Error("Unexpected error") } } diff --git a/realize/projects.go b/realize/projects.go index 0abf80b..774018e 100644 --- a/realize/projects.go +++ b/realize/projects.go @@ -343,7 +343,7 @@ L: // Validate a file path func (p *Project) Validate(path string, fcheck bool) bool { - if len(path) <= 0 { + if len(path) == 0 { return false } // check if skip hidden diff --git a/realize_test.go b/realize_test.go index caf17fd..2bc6e0b 100644 --- a/realize_test.go +++ b/realize_test.go @@ -56,7 +56,7 @@ func TestRealize_add(t *testing.T) { if err := m.add(); err != nil { t.Error("Unexpected error") } - if len(m.Projects) <= 0 { + if len(m.Projects) == 0 { t.Error("Unexpected error") }