mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
fix(backend): enable more Go linters
This commit is contained in:
committed by
Łukasz Mierzwa
parent
f325dd7590
commit
689866a64c
+1
-3
@@ -17,9 +17,7 @@ const (
|
||||
aclActionAllow = "allow"
|
||||
)
|
||||
|
||||
var (
|
||||
allACLActions = []string{aclActionAllow, aclActionBlock, aclActionRequireMatcher}
|
||||
)
|
||||
var allACLActions = []string{aclActionAllow, aclActionBlock, aclActionRequireMatcher}
|
||||
|
||||
type silenceFilter struct {
|
||||
Name string
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func getFiltersFromQuery(filterStrings []string) []filters.FilterT {
|
||||
return matchFilters
|
||||
}
|
||||
|
||||
func countLabel(countStore map[string]map[string]int, key string, val string) {
|
||||
func countLabel(countStore map[string]map[string]int, key, val string) {
|
||||
if _, found := countStore[key]; !found {
|
||||
countStore[key] = make(map[string]int)
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ func contentText(w http.ResponseWriter) {
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
}
|
||||
|
||||
func serveFileOr404(path string, contentType string) http.HandlerFunc {
|
||||
func serveFileOr404(path, contentType string) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
if path == "" {
|
||||
|
||||
@@ -124,7 +124,7 @@ func TestStaticFiles(t *testing.T) {
|
||||
mime string
|
||||
}
|
||||
|
||||
var staticFileTests = []staticFileTestCase{
|
||||
staticFileTests := []staticFileTestCase{
|
||||
{
|
||||
path: "/favicon.ico",
|
||||
code: 200,
|
||||
@@ -185,7 +185,7 @@ func TestStaticFilesPrefix(t *testing.T) {
|
||||
mime string
|
||||
}
|
||||
|
||||
var staticFilePrefixTests = []staticFileTestCase{
|
||||
staticFilePrefixTests := []staticFileTestCase{
|
||||
{
|
||||
path: "/sub/favicon.ico",
|
||||
code: 200,
|
||||
|
||||
@@ -64,7 +64,7 @@ func TestAuthHeader(t *testing.T) {
|
||||
defer httpmock.DeactivateAndReset()
|
||||
|
||||
for _, testCase := range authHeaderTests {
|
||||
testCase := testCase //scopelint pin
|
||||
testCase := testCase // scopelint pin
|
||||
for _, version := range mock.ListAllMocks() {
|
||||
apiCache, _ = lru.New(100)
|
||||
|
||||
@@ -85,7 +85,8 @@ func TestAuthHeader(t *testing.T) {
|
||||
"metrics",
|
||||
"api/v2/status",
|
||||
"api/v2/silences",
|
||||
"api/v2/alerts/groups"} {
|
||||
"api/v2/alerts/groups",
|
||||
} {
|
||||
|
||||
uri := fmt.Sprintf("%s/%s", testCase.alertmanagerURI, m)
|
||||
|
||||
|
||||
+3
-2
@@ -167,7 +167,7 @@ func setupRouter(router *chi.Mux, historyPoller *historyPoller) {
|
||||
}
|
||||
}
|
||||
|
||||
walkFunc := func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
|
||||
walkFunc := func(method, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
|
||||
log.Debug().
|
||||
Str("method", method).
|
||||
Str("route", route).
|
||||
@@ -235,6 +235,7 @@ func setupUpstreams() error {
|
||||
func msgFormatter(msg any) string {
|
||||
return fmt.Sprintf("msg=%q", msg)
|
||||
}
|
||||
|
||||
func lvlFormatter(level any) string {
|
||||
if level == nil {
|
||||
return ""
|
||||
@@ -425,7 +426,7 @@ func writePidFile() error {
|
||||
if pidFile != "" {
|
||||
log.Info().Str("path", pidFile).Msg("Writing PID file")
|
||||
pid := os.Getpid()
|
||||
err := os.WriteFile(pidFile, []byte(strconv.Itoa(pid)), 0644)
|
||||
err := os.WriteFile(pidFile, []byte(strconv.Itoa(pid)), 0o644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write a PID file: %w", err)
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ func TestProxyHeaders(t *testing.T) {
|
||||
defer httpmock.DeactivateAndReset()
|
||||
|
||||
for _, testCase := range proxyHeaderTests {
|
||||
testCase := testCase //scopelint pin
|
||||
testCase := testCase // scopelint pin
|
||||
r := testRouter()
|
||||
am, err := alertmanager.NewAlertmanager(
|
||||
"cluster",
|
||||
|
||||
@@ -43,7 +43,6 @@ func TestMain(m *testing.M) {
|
||||
ecode = 1
|
||||
}
|
||||
os.Exit(ecode)
|
||||
|
||||
}
|
||||
|
||||
func TestScripts(t *testing.T) {
|
||||
|
||||
@@ -209,9 +209,9 @@ level=info msg=" key: \"\""
|
||||
level=info msg=" port: 1234"
|
||||
level=info msg=" prefix: /prefix/"
|
||||
level=info msg="log:"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" level: info"
|
||||
level=info msg=" format: text"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" requests: false"
|
||||
level=info msg=" timestamp: false"
|
||||
level=info msg="receivers:"
|
||||
|
||||
@@ -242,9 +242,9 @@ level=info msg=" key: \"\""
|
||||
level=info msg=" port: 8080"
|
||||
level=info msg=" prefix: /"
|
||||
level=info msg="log:"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" level: info"
|
||||
level=info msg=" format: text"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" requests: false"
|
||||
level=info msg=" timestamp: false"
|
||||
level=info msg="receivers:"
|
||||
|
||||
@@ -104,9 +104,9 @@ level=info msg=" key: \"\""
|
||||
level=info msg=" port: 8080"
|
||||
level=info msg=" prefix: /"
|
||||
level=info msg="log:"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" level: info"
|
||||
level=info msg=" format: text"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" requests: false"
|
||||
level=info msg=" timestamp: false"
|
||||
level=info msg="receivers:"
|
||||
|
||||
@@ -104,9 +104,9 @@ level=info msg=" key: \"\""
|
||||
level=info msg=" port: 8080"
|
||||
level=info msg=" prefix: /"
|
||||
level=info msg="log:"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" level: info"
|
||||
level=info msg=" format: text"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" requests: false"
|
||||
level=info msg=" timestamp: false"
|
||||
level=info msg="receivers:"
|
||||
|
||||
@@ -104,9 +104,9 @@ level=info msg=" key: \"\""
|
||||
level=info msg=" port: 8080"
|
||||
level=info msg=" prefix: /"
|
||||
level=info msg="log:"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" level: info"
|
||||
level=info msg=" format: text"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" requests: false"
|
||||
level=info msg=" timestamp: false"
|
||||
level=info msg="receivers:"
|
||||
|
||||
@@ -114,9 +114,9 @@ level=info msg=" key: \"\""
|
||||
level=info msg=" port: 8080"
|
||||
level=info msg=" prefix: /"
|
||||
level=info msg="log:"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" level: info"
|
||||
level=info msg=" format: text"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" requests: false"
|
||||
level=info msg=" timestamp: false"
|
||||
level=info msg="receivers:"
|
||||
|
||||
@@ -104,9 +104,9 @@ level=info msg=" key: \"\""
|
||||
level=info msg=" port: 8080"
|
||||
level=info msg=" prefix: /"
|
||||
level=info msg="log:"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" level: info"
|
||||
level=info msg=" format: text"
|
||||
level=info msg=" config: true"
|
||||
level=info msg=" requests: false"
|
||||
level=info msg=" timestamp: false"
|
||||
level=info msg="receivers:"
|
||||
|
||||
+1
-1
@@ -680,7 +680,7 @@ func silences(w http.ResponseWriter, r *http.Request) {
|
||||
recentFirst = false
|
||||
}
|
||||
|
||||
sort.Slice(dedupedSilences, func(i int, j int) bool {
|
||||
sort.Slice(dedupedSilences, func(i, j int) bool {
|
||||
if dedupedSilences[i].Silence.EndsAt.Equal(dedupedSilences[j].Silence.EndsAt) {
|
||||
if dedupedSilences[i].Silence.StartsAt.Equal(dedupedSilences[j].Silence.StartsAt) {
|
||||
return dedupedSilences[i].Silence.ID < dedupedSilences[j].Silence.ID
|
||||
|
||||
@@ -3044,6 +3044,7 @@ func (ew *gzErrWriter) Write(p []byte) (n int, err error) {
|
||||
}
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (ew *gzErrWriter) Close() error {
|
||||
if ew.failClose {
|
||||
return errors.New("Close error")
|
||||
|
||||
Reference in New Issue
Block a user