Skip to content

Commit

Permalink
Fix gocritic emptyStringTest issues
Browse files Browse the repository at this point in the history
See,
$ golangci-lint run --disable-all --enable=gocritic --skip-dirs vim25/xml --config ./.golangci.yml | grep emptyStringTest
find/finder.go:256:5: emptyStringTest: replace `len(path) == 0` with `path == ""` (gocritic)
govc/datastore/ls.go:204:8: emptyStringTest: replace `len(p) != 0` with `p != ""` (gocritic)
  • Loading branch information
mjtrangoni committed Feb 19, 2019
1 parent 63ba923 commit 89b5331
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestNewClient(t *testing.T) {
if err != nil {
return err
}
if len(x.Name) == 0 {
if x.Name == "" {
return errors.New("empty response")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion find/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (f *Finder) managedObjectList(ctx context.Context, path string, tl bool, in
fn = f.dcReference
}

if len(path) == 0 {
if path == "" {
path = "."
}

Expand Down
2 changes: 1 addition & 1 deletion govc/datastore/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (o *listOutput) add(r types.HostDatastoreBrowserSearchResults) {
}

for _, p := range path {
if len(p) != 0 && p[0] == '.' {
if p != "" && p[0] == '.' {
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion object/datastore_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type DatastorePath struct {
// FromString parses a datastore path.
// Returns true if the path could be parsed, false otherwise.
func (p *DatastorePath) FromString(s string) bool {
if len(s) == 0 {
if s == "" {
return false
}

Expand Down

0 comments on commit 89b5331

Please sign in to comment.