Skip to content

Commit 7670a49

Browse files
Merge pull request #14 from fabricekabongo/deepsource-autofix-9bad033b
refactor: fix check for empty string
2 parents ddc93eb + 2dc57c0 commit 7670a49

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

server/listener.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package server
22

33
import (
44
"bufio"
5-
"github.com/fabricekabongo/loggerhead/query"
6-
"github.com/prometheus/client_golang/prometheus"
7-
"github.com/prometheus/client_golang/prometheus/promauto"
85
"log"
96
"net"
107
"time"
8+
9+
"github.com/fabricekabongo/loggerhead/query"
10+
"github.com/prometheus/client_golang/prometheus"
11+
"github.com/prometheus/client_golang/prometheus/promauto"
1112
)
1213

1314
var (
@@ -117,7 +118,7 @@ func (h *Handler) handleConnection(conn net.Conn) error {
117118
}
118119
startOfEOF = time.Time{}
119120
line := scanner.Text()
120-
if len(line) == 0 {
121+
if line == "" {
121122
log.Println("Empty line received. Closing connection")
122123
break
123124
}

world/location.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ type Location struct {
3535
}
3636

3737
func NewLocation(ns string, id string, lat float64, lon float64) (*Location, error) {
38-
if len(id) == 0 {
38+
if id == "" {
3939
validationOps.Inc()
4040
return nil, LocationErrorRequiredId
4141
}
42-
if len(ns) == 0 {
42+
if ns == "" {
4343
validationOps.Inc()
4444
return nil, LocationErrorRequiredNamespace
4545
}
@@ -60,11 +60,11 @@ func NewLocation(ns string, id string, lat float64, lon float64) (*Location, err
6060
}
6161

6262
func (*Location) init(ns string, id string, lat float64, lon float64) (*Location, error) {
63-
if len(id) == 0 {
63+
if id == "" {
6464
validationOps.Inc()
6565
return nil, LocationErrorRequiredId
6666
}
67-
if len(ns) == 0 {
67+
if ns == "" {
6868
validationOps.Inc()
6969
return nil, LocationErrorRequiredNamespace
7070
}

0 commit comments

Comments
 (0)