Skip to content

Commit

Permalink
refactor: fix check for empty string
Browse files Browse the repository at this point in the history
It is not recommended to use `len` for empty string test.
  • Loading branch information
deepsource-autofix[bot] authored Oct 11, 2024
1 parent 87f3c2e commit 949198d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions extra/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ func main() {
}

sslKey := os.Getenv("UPTIME_KUMA_SSL_KEY")
if len(sslKey) == 0 {
if sslKey == "" {
sslKey = os.Getenv("SSL_KEY")
}

sslCert := os.Getenv("UPTIME_KUMA_SSL_CERT")
if len(sslCert) == 0 {
if sslCert == "" {
sslCert = os.Getenv("SSL_CERT")
}

hostname := os.Getenv("UPTIME_KUMA_HOST")
if len(hostname) == 0 && !isFreeBSD {
if hostname == "" && !isFreeBSD {
hostname = os.Getenv("HOST")
}
if len(hostname) == 0 {
if hostname == "" {
hostname = "127.0.0.1"
}

Expand All @@ -54,15 +54,15 @@ func main() {
if !isK8s {
port = os.Getenv("UPTIME_KUMA_PORT")
}
if len(port) == 0 {
if port == "" {
port = os.Getenv("PORT")
}
if len(port) == 0 {
if port == "" {
port = "3001"
}

protocol := ""
if len(sslKey) != 0 && len(sslCert) != 0 {
if sslKey != "" && sslCert != "" {
protocol = "https"
} else {
protocol = "http"
Expand Down

0 comments on commit 949198d

Please sign in to comment.