fix(backend): fix problems found by new linters

This commit is contained in:
Łukasz Mierzwa
2019-08-18 10:58:26 +01:00
parent 96826a8176
commit 29b6c7baae
7 changed files with 10 additions and 2 deletions
+2
View File
@@ -31,6 +31,7 @@ func DedupAlerts() []models.AlertGroup {
alerts := map[string]models.Alert{}
for _, ag := range agList {
for _, alert := range ag.Alerts {
alert := alert // scopelint pin
// remove all alerts for receiver(s) that the user doesn't
// want to see in the UI
if transform.StripReceivers(config.Config.Receivers.Keep, config.Config.Receivers.Strip, alert.Receiver) {
@@ -66,6 +67,7 @@ func DedupAlerts() []models.AlertGroup {
ag := models.AlertGroup(agList[0])
ag.Alerts = models.AlertList{}
for _, alert := range alerts {
alert := alert // scopelint pin
// strip labels and annotations user doesn't want to see in the UI
alert.Labels = transform.StripLables(config.Config.Labels.Keep, config.Config.Labels.Strip, alert.Labels)
alert.Annotations = transform.StripAnnotations(config.Config.Annotations.Keep, config.Config.Annotations.Strip, alert.Annotations)
+1
View File
@@ -182,6 +182,7 @@ func (am *Alertmanager) pullSilences(version string) error {
log.Infof("[%s] Detecting JIRA links in silences (%d)", am.Name, len(silences))
silenceMap := map[string]models.Silence{}
for _, silence := range silences {
silence := silence // scopelint pin
silence.JiraID, silence.JiraURL = transform.DetectJIRAs(&silence)
silenceMap[silence.ID] = silence
}
+1 -1
View File
@@ -15,9 +15,9 @@ import (
type filterTest struct {
Expression string
IsValid bool
IsMatch bool
Alert models.Alert
Silence models.Silence
IsMatch bool
}
var tests = []filterTest{
+3
View File
@@ -153,9 +153,12 @@ var agFPTests = []agFPTest{
func TestAlertGroupContentFingerprint(t *testing.T) {
fps := []string{}
for i, testCase := range agFPTests {
i := i // scopelint pin
testCase := testCase // scopelint pin
t.Run(testCase.name, func(t *testing.T) {
alerts := models.AlertList{}
for _, alert := range testCase.ag.Alerts {
alert := alert // scopelint pin
alert.UpdateFingerprints()
alerts = append(alerts, alert)
}
+1 -1
View File
@@ -31,8 +31,8 @@ func getFileSize(path string) int64 {
type httpTransportTest struct {
timeout time.Duration
useTLS bool
tlsConfig *tls.Config
useTLS bool
failed bool
headers map[string]string
}
+1
View File
@@ -178,6 +178,7 @@ func TestProxyHeaders(t *testing.T) {
defer httpmock.DeactivateAndReset()
for _, testCase := range proxyHeaderTests {
testCase := testCase //scopelint pin
r := ginTestEngine()
am, err := alertmanager.NewAlertmanager(
"dummy",
+1
View File
@@ -230,6 +230,7 @@ func alerts(c *gin.Context) {
}
for _, alert := range ag.Alerts {
alert := alert // scopelint pin
results := []bool{}
if validFilters {
for _, filter := range matchFilters {