Skip to content

Commit ee44165

Browse files
author
Allen
committed
Fix some quality issues, add .deepsource.toml
Signed-off-by: Allen <allen@deepsource.io>
1 parent b426c1b commit ee44165

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.deepsource.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version = 1
2+
test_patterns = [
3+
"*_test.go"
4+
]
5+
exclude_patterns = [
6+
"examples/**",
7+
"vendor/**"
8+
]
9+
[[analyzers]]
10+
name = "go"
11+
enabled = true
12+
[analyzers.meta]
13+
import_path = "github.com/messagebird/sachet"

cmd/sachet/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
"github.com/prometheus/alertmanager/template"
3434
"github.com/prometheus/client_golang/prometheus"
35+
"github.com/prometheus/client_golang/prometheus/promhttp"
3536

3637
"github.com/heptiolabs/healthcheck"
3738
)
@@ -122,7 +123,7 @@ func main() {
122123
requestTotal.WithLabelValues("200", receiverConf.Provider).Inc()
123124
})
124125

125-
http.Handle("/metrics", prometheus.Handler())
126+
http.Handle("/metrics", promhttp.Handler())
126127

127128
http.HandleFunc("/-/reload", func(w http.ResponseWriter, r *http.Request) {
128129
defer r.Body.Close()
@@ -218,7 +219,7 @@ func errorHandler(w http.ResponseWriter, status int, err error, provider string)
218219
}
219220
// respond json
220221
bytes, _ := json.Marshal(data)
221-
json := string(bytes[:])
222+
json := string(bytes)
222223
fmt.Fprint(w, json)
223224

224225
log.Println("Error: " + json)

provider/aliyun/aliyun.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (aliyun *Aliyun) Send(message sachet.Message) error {
5252
var response *dysmsapi.SendSmsResponse
5353
response, err = aliyun.client.SendSms(request)
5454
if err == nil && (!response.IsSuccess() || response.Code != "OK") {
55-
err = fmt.Errorf(response.String())
55+
return fmt.Errorf(response.String())
5656
}
5757
}
5858
default:

0 commit comments

Comments
 (0)