mirror of
https://github.com/prymitive/karma
synced 2026-08-28 11:17:28 +00:00
fix(tests): fix linter errors
This commit is contained in:
committed by
Łukasz Mierzwa
parent
caef55c586
commit
ee85d2e25a
+1
-1
@@ -251,7 +251,7 @@ func lvlFormatter(level any) string {
|
||||
return fmt.Sprintf("level=%s", level)
|
||||
}
|
||||
|
||||
func discardFormatter(msg any) string {
|
||||
func discardFormatter(_ any) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -1362,7 +1362,7 @@ func TestProxySilenceACL(t *testing.T) {
|
||||
|
||||
type errReader int
|
||||
|
||||
func (errReader) Read(p []byte) (n int, err error) {
|
||||
func (errReader) Read(_ []byte) (n int, err error) {
|
||||
return 0, errors.New("request read error")
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ func TestScripts(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func httpServer(ts *testscript.TestScript, neg bool, args []string) {
|
||||
func httpServer(ts *testscript.TestScript, _ bool, args []string) {
|
||||
mocks := ts.Value("mocks").(*httpMocks)
|
||||
|
||||
if len(args) == 0 {
|
||||
@@ -253,7 +253,7 @@ func (m *httpMocks) add(name string, mock httpMock) {
|
||||
m.responses[name] = append(m.responses[name], mock)
|
||||
}
|
||||
|
||||
func tlsCert(ts *testscript.TestScript, neg bool, args []string) {
|
||||
func tlsCert(ts *testscript.TestScript, _ bool, args []string) {
|
||||
if len(args) < 2 {
|
||||
ts.Fatalf("! cert command requires '$DIRNAME $NAME' args, got [%s]", strings.Join(args, " "))
|
||||
}
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ type KarmaVersion struct {
|
||||
Golang string `json:"golang"`
|
||||
}
|
||||
|
||||
func versionHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func versionHandler(w http.ResponseWriter, _ *http.Request) {
|
||||
ver := KarmaVersion{
|
||||
Version: version,
|
||||
Golang: runtime.Version(),
|
||||
@@ -55,11 +55,11 @@ func versionHandler(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write(data)
|
||||
}
|
||||
|
||||
func pong(w http.ResponseWriter, r *http.Request) {
|
||||
func pong(w http.ResponseWriter, _ *http.Request) {
|
||||
_, _ = w.Write([]byte("Pong\n"))
|
||||
}
|
||||
|
||||
func robots(w http.ResponseWriter, r *http.Request) {
|
||||
func robots(w http.ResponseWriter, _ *http.Request) {
|
||||
_, _ = w.Write([]byte("User-agent: *\nDisallow: /\n"))
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func redirectIndex(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, r.URL.Path+"/", http.StatusMovedPermanently)
|
||||
}
|
||||
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
func index(w http.ResponseWriter, _ *http.Request) {
|
||||
noCache(w)
|
||||
pushPath(w, getViewURL("/custom.css"))
|
||||
pushPath(w, getViewURL("/custom.js"))
|
||||
|
||||
@@ -307,7 +307,7 @@ func TestUrlSecretTest(t *testing.T) {
|
||||
}
|
||||
|
||||
// FIXME check logged values
|
||||
func TestLogValues(t *testing.T) {
|
||||
func TestLogValues(_ *testing.T) {
|
||||
_, _ = mockConfigRead()
|
||||
Config.LogValues()
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (filter *ageFilter) init(name string, matcher *matcherT, rawText string, is
|
||||
}
|
||||
}
|
||||
|
||||
func (filter *ageFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *ageFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
ts := time.Now().Add(filter.Value.(time.Duration))
|
||||
isMatch := filter.Matcher.Compare(int(ts.Unix()), int(alert.StartsAt.Unix()))
|
||||
@@ -55,7 +55,7 @@ func newAgeFilter() FilterT {
|
||||
return &f
|
||||
}
|
||||
|
||||
func ageAutocomplete(name string, operators []string, alerts []models.Alert) []models.Autocomplete {
|
||||
func ageAutocomplete(name string, operators []string, _ []models.Alert) []models.Autocomplete {
|
||||
tokens := make([]models.Autocomplete, 0, len(operators)*2)
|
||||
for _, operator := range operators {
|
||||
tokens = append(tokens, makeAC(
|
||||
|
||||
@@ -11,7 +11,7 @@ type alertmanagerInstanceFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *alertmanagerInstanceFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *alertmanagerInstanceFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -11,7 +11,7 @@ type alertmanagerClusterFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *alertmanagerClusterFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *alertmanagerClusterFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -10,7 +10,7 @@ type fingerprintFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *fingerprintFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *fingerprintFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -24,7 +24,7 @@ func (filter *fuzzyFilter) init(name string, matcher *matcherT, rawText string,
|
||||
}
|
||||
}
|
||||
|
||||
func (filter *fuzzyFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *fuzzyFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
for _, val := range alert.Annotations {
|
||||
if filter.Matcher.Compare(val.Value, filter.Value) {
|
||||
|
||||
@@ -33,7 +33,7 @@ func (filter *inhibitedFilter) init(name string, matcher *matcherT, rawText stri
|
||||
}
|
||||
}
|
||||
|
||||
func (filter *inhibitedFilter) Match(alert *models.Alert, matches int) (isMatch bool) {
|
||||
func (filter *inhibitedFilter) Match(alert *models.Alert, _ int) (isMatch bool) {
|
||||
if filter.IsValid {
|
||||
for _, am := range alert.Alertmanager {
|
||||
m := filter.Matcher.Compare(len(am.InhibitedBy) > 0, filter.Value)
|
||||
@@ -60,7 +60,7 @@ func newInhibitedFilter() FilterT {
|
||||
return &f
|
||||
}
|
||||
|
||||
func inhibitedAutocomplete(name string, operators []string, alerts []models.Alert) []models.Autocomplete {
|
||||
func inhibitedAutocomplete(name string, _ []string, _ []models.Alert) []models.Autocomplete {
|
||||
tokens := map[string]models.Autocomplete{}
|
||||
|
||||
for _, val := range []string{trueValue, falseValue} {
|
||||
|
||||
@@ -11,7 +11,7 @@ type inhibitedByFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *inhibitedByFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *inhibitedByFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -4,7 +4,7 @@ type alwaysInvalidFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *alwaysInvalidFilter) init(name string, matcher *matcherT, rawText string, isValid bool, value string) {
|
||||
func (filter *alwaysInvalidFilter) init(name string, _ *matcherT, rawText string, _ bool, _ string) {
|
||||
filter.Matched = name
|
||||
filter.RawText = rawText
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ type labelFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *labelFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *labelFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
isMatch := filter.Matcher.Compare(alert.Labels.GetValue(filter.Matched), filter.Value)
|
||||
if isMatch {
|
||||
@@ -29,7 +29,7 @@ func newLabelFilter() FilterT {
|
||||
return &f
|
||||
}
|
||||
|
||||
func labelAutocomplete(name string, operators []string, alerts []models.Alert) []models.Autocomplete {
|
||||
func labelAutocomplete(_ string, operators []string, alerts []models.Alert) []models.Autocomplete {
|
||||
tokens := map[string]models.Autocomplete{}
|
||||
for _, alert := range alerts {
|
||||
for _, l := range alert.Labels {
|
||||
|
||||
@@ -29,7 +29,7 @@ func (filter *limitFilter) init(name string, matcher *matcherT, rawText string,
|
||||
}
|
||||
}
|
||||
|
||||
func (filter *limitFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *limitFilter) Match(_ *models.Alert, matches int) bool {
|
||||
if filter.IsValid {
|
||||
if matches < filter.Value.(int) {
|
||||
return true
|
||||
@@ -46,7 +46,7 @@ func newLimitFilter() FilterT {
|
||||
return &f
|
||||
}
|
||||
|
||||
func limitAutocomplete(name string, operators []string, alerts []models.Alert) []models.Autocomplete {
|
||||
func limitAutocomplete(name string, operators []string, _ []models.Alert) []models.Autocomplete {
|
||||
tokens := make([]models.Autocomplete, 0, len(operators)*2)
|
||||
for _, operator := range operators {
|
||||
tokens = append(tokens, makeAC(
|
||||
|
||||
@@ -11,7 +11,7 @@ type receiverFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *receiverFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *receiverFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
isMatch := filter.Matcher.Compare(alert.Receiver, filter.Value)
|
||||
if isMatch {
|
||||
|
||||
@@ -11,7 +11,7 @@ type silenceAuthorFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *silenceAuthorFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *silenceAuthorFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -11,7 +11,7 @@ type silenceTicketFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *silenceTicketFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *silenceTicketFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -11,7 +11,7 @@ type silenceIDFilter struct {
|
||||
alertFilter
|
||||
}
|
||||
|
||||
func (filter *silenceIDFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *silenceIDFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -25,7 +25,7 @@ func (filter *stateFilter) init(name string, matcher *matcherT, rawText string,
|
||||
}
|
||||
}
|
||||
|
||||
func (filter *stateFilter) Match(alert *models.Alert, matches int) bool {
|
||||
func (filter *stateFilter) Match(alert *models.Alert, _ int) bool {
|
||||
if filter.IsValid {
|
||||
var isMatch bool
|
||||
for _, am := range alert.Alertmanager {
|
||||
|
||||
@@ -17,7 +17,7 @@ func GetAbsoluteMockPath(filename, version string) string {
|
||||
}
|
||||
|
||||
// GetMockResponder returns a httpmock.Responder for given file/version
|
||||
func GetMockResponder(url, version, filename string) httpmock.Responder {
|
||||
func GetMockResponder(_, version, filename string) httpmock.Responder {
|
||||
fullPath := GetAbsoluteMockPath(filename, version)
|
||||
mockJSON, _ := os.ReadFile(fullPath)
|
||||
return httpmock.NewBytesResponder(200, mockJSON)
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ type Reader interface {
|
||||
|
||||
// NewReader creates an instance of URIReader that can handle URI schema
|
||||
// for the passed uri string
|
||||
func NewReader(uri string, timeout time.Duration, clientTransport http.RoundTripper, headers map[string]string) (Reader, error) {
|
||||
func NewReader(uri string, timeout time.Duration, clientTransport http.RoundTripper, _ map[string]string) (Reader, error) {
|
||||
u, err := url.Parse(uri)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user