Skip to content

Commit

Permalink
Merge pull request cloudflare#579 from cloudflare/dependabot/go_modul…
Browse files Browse the repository at this point in the history
…es/tools/golangci-lint/github.com/golangci/golangci-lint-1.52.0

Bump github.com/golangci/golangci-lint from 1.51.2 to 1.52.0 in /tools/golangci-lint
  • Loading branch information
prymitive authored Mar 20, 2023
2 parents e29b488 + 0939054 commit f02d2be
Show file tree
Hide file tree
Showing 39 changed files with 173 additions and 233 deletions.
2 changes: 1 addition & 1 deletion cmd/pint/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/pint/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var versionCmd = &cli.Command{
Action: actionVersion,
}

func actionVersion(c *cli.Context) (err error) {
func actionVersion(_ *cli.Context) error {
fmt.Printf("%s (revision: %s)\n", version, commit)
return nil
}
2 changes: 1 addition & 1 deletion cmd/pint/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func actionWatch(c *cli.Context) error {
return nil
}

func startTimer(ctx context.Context, cfg config.Config, workers int, interval time.Duration, ack chan bool, collector *problemCollector) chan bool {
func startTimer(ctx context.Context, _ config.Config, workers int, interval time.Duration, ack chan bool, collector *problemCollector) chan bool {
ticker := time.NewTicker(time.Second)
stop := make(chan bool, 1)
wasBootstrapped := false
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/alerts_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c AnnotationCheck) Reporter() string {
return AnnotationCheckName
}

func (c AnnotationCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c AnnotationCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.AlertingRule == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/alerts_comparison.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c ComparisonCheck) Reporter() string {
return ComparisonCheckName
}

func (c ComparisonCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c ComparisonCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.AlertingRule == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/alerts_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (c AlertsCheck) Reporter() string {
return AlertsCheckName
}

func (c AlertsCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c AlertsCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.AlertingRule == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/alerts_for.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c AlertsForChecksFor) Reporter() string {
return AlertForCheckName
}

func (c AlertsForChecksFor) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c AlertsForChecksFor) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.AlertingRule == nil || rule.AlertingRule.For == nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions internal/checks/alerts_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (c TemplateCheck) Reporter() string {
return TemplateCheckName
}

func (c TemplateCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c TemplateCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.AlertingRule == nil {
return nil
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func (c TemplateCheck) checkHumanizeIsNeeded(node *parser.PromQLNode) (problems
return problems
}

func queryFunc(ctx context.Context, expr string, ts time.Time) (promql.Vector, error) {
func queryFunc(_ context.Context, expr string, _ time.Time) (promql.Vector, error) {
if _, err := promParser.ParseExpr(expr); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ type RuleChecker interface {
String() string
Reporter() string
Meta() CheckMeta
Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) []Problem
Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) []Problem
}

type exprProblem struct {
Expand Down
16 changes: 8 additions & 8 deletions internal/checks/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func newSimpleProm(uri string) *promapi.FailoverGroup {
return simpleProm("prom", uri, time.Second*5, true)
}

func noProm(uri string) *promapi.FailoverGroup {
func noProm(_ string) *promapi.FailoverGroup {
return nil
}

Expand Down Expand Up @@ -194,7 +194,7 @@ func mustParseContent(content string) (entries []discovery.Entry) {
return entries
}

func noProblems(uri string) []checks.Problem {
func noProblems(_ string) []checks.Problem {
return nil
}

Expand Down Expand Up @@ -277,7 +277,7 @@ type promError struct {
err string
}

func (pe promError) respond(w http.ResponseWriter, r *http.Request) {
func (pe promError) respond(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(pe.code)
w.Header().Set("Content-Type", "application/json")
perr := struct {
Expand All @@ -300,7 +300,7 @@ type vectorResponse struct {
samples model.Vector
}

func (vr vectorResponse) respond(w http.ResponseWriter, r *http.Request) {
func (vr vectorResponse) respond(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(200)
w.Header().Set("Content-Type", "application/json")
result := struct {
Expand Down Expand Up @@ -379,7 +379,7 @@ type configResponse struct {
yaml string
}

func (cr configResponse) respond(w http.ResponseWriter, r *http.Request) {
func (cr configResponse) respond(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(200)
w.Header().Set("Content-Type", "application/json")
result := struct {
Expand All @@ -400,7 +400,7 @@ type flagsResponse struct {
flags map[string]string
}

func (fg flagsResponse) respond(w http.ResponseWriter, r *http.Request) {
func (fg flagsResponse) respond(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(200)
w.Header().Set("Content-Type", "application/json")
result := struct {
Expand All @@ -421,7 +421,7 @@ type metadataResponse struct {
metadata map[string][]v1.Metadata
}

func (mr metadataResponse) respond(w http.ResponseWriter, r *http.Request) {
func (mr metadataResponse) respond(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(200)
w.Header().Set("Content-Type", "application/json")
// _, _ = w.Write([]byte(`{"status":"success","data":{"gauge":[{"type":"gauge","help":"Text","unit":""}]}}`))
Expand All @@ -443,7 +443,7 @@ type sleepResponse struct {
sleep time.Duration
}

func (sr sleepResponse) respond(w http.ResponseWriter, r *http.Request) {
func (sr sleepResponse) respond(_ http.ResponseWriter, _ *http.Request) {
time.Sleep(sr.sleep)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/checks/labels_conflict.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (c LabelsConflictCheck) Reporter() string {
return LabelsConflictCheckName
}

func (c LabelsConflictCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c LabelsConflictCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.RecordingRule == nil || rule.RecordingRule.Expr.SyntaxError != nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c AggregationCheck) Reporter() string {
return AggregationCheckName
}

func (c AggregationCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c AggregationCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
expr := rule.Expr()
if expr.SyntaxError != nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_fragile.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c FragileCheck) Reporter() string {
return FragileCheckName
}

func (c FragileCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c FragileCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
expr := rule.Expr()
if expr.SyntaxError != nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_range_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c RangeQueryCheck) Reporter() string {
return RangeQueryCheckName
}

func (c RangeQueryCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c RangeQueryCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
expr := rule.Expr()

if expr.SyntaxError != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (c RateCheck) Reporter() string {
return RateCheckName
}

func (c RateCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c RateCheck) Check(ctx context.Context, _ string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
expr := rule.Expr()

if expr.SyntaxError != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (c RegexpCheck) Reporter() string {
return RegexpCheckName
}

func (c RegexpCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c RegexpCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
expr := rule.Expr()
if expr.SyntaxError != nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c SeriesCheck) Reporter() string {
return SeriesCheckName
}

func (c SeriesCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c SeriesCheck) Check(ctx context.Context, _ string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
var settings *PromqlSeriesSettings
if s := ctx.Value(SettingsKey(c.Reporter())); s != nil {
settings = s.(*PromqlSeriesSettings)
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_syntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c SyntaxCheck) Reporter() string {
return SyntaxCheckName
}

func (c SyntaxCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c SyntaxCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
q := rule.Expr()
if q.SyntaxError != nil {
problems = append(problems, Problem{
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/promql_vector_matching.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c VectorMatchingCheck) Reporter() string {
return VectorMatchingCheckName
}

func (c VectorMatchingCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c VectorMatchingCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
expr := rule.Expr()
if expr.SyntaxError != nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/query_cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c CostCheck) Reporter() string {
return CostCheckName
}

func (c CostCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c CostCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
expr := rule.Expr()

if expr.SyntaxError != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/rule_duplicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c RuleDuplicateCheck) Check(ctx context.Context, path string, rule parser.
return problems
}

func (c RuleDuplicateCheck) compareRules(ctx context.Context, rule *parser.RecordingRule, entry discovery.Entry) (problems []Problem) {
func (c RuleDuplicateCheck) compareRules(_ context.Context, rule *parser.RecordingRule, entry discovery.Entry) (problems []Problem) {
ruleALabels := buildRuleLabels(rule)
ruleBLabels := buildRuleLabels(entry.Rule.RecordingRule)

Expand Down
2 changes: 1 addition & 1 deletion internal/checks/rule_for.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (c RuleForCheck) Reporter() string {
return RuleForCheckName
}

func (c RuleForCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c RuleForCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.AlertingRule == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/rule_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (c LabelCheck) Reporter() string {
return LabelCheckName
}

func (c LabelCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c LabelCheck) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.RecordingRule != nil {
problems = append(problems, c.checkRecordingRule(rule)...)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/rule_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c RuleLinkCheck) Reporter() string {
return RuleLinkCheckName
}

func (c RuleLinkCheck) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c RuleLinkCheck) Check(ctx context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if rule.AlertingRule == nil || rule.AlertingRule.Annotations == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/rule_reject.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c Reject) Reporter() string {
return RejectCheckName
}

func (c Reject) Check(ctx context.Context, path string, rule parser.Rule, entries []discovery.Entry) (problems []Problem) {
func (c Reject) Check(_ context.Context, _ string, rule parser.Rule, _ []discovery.Entry) (problems []Problem) {
if c.checkLabels && rule.AlertingRule != nil && rule.AlertingRule.Labels != nil {
for _, label := range rule.AlertingRule.Labels.Items {
problems = append(problems, c.reject(rule, label, "label")...)
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (cfg *Config) GetChecksForRule(ctx context.Context, path string, r parser.R
}

for _, rule := range cfg.Rules {
allChecks = append(allChecks, rule.resolveChecks(ctx, path, r, cfg.Checks.Enabled, cfg.Checks.Disabled, proms)...)
allChecks = append(allChecks, rule.resolveChecks(ctx, path, r, proms)...)
}

for _, cm := range allChecks {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (rule Rule) validate() (err error) {
return nil
}

func (rule Rule) resolveChecks(ctx context.Context, path string, r parser.Rule, enabledChecks, disabledChecks []string, prometheusServers []*promapi.FailoverGroup) []checkMeta {
func (rule Rule) resolveChecks(ctx context.Context, path string, r parser.Rule, prometheusServers []*promapi.FailoverGroup) []checkMeta {
enabled := []checkMeta{}

for _, ignore := range rule.Ignore {
Expand Down
2 changes: 1 addition & 1 deletion internal/discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type failingReader struct {
err error
}

func (r failingReader) Read(p []byte) (int, error) {
func (r failingReader) Read(_ []byte) (int, error) {
return 0, r.err
}

Expand Down
12 changes: 2 additions & 10 deletions internal/parser/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,10 @@ func newYamlNode(node *yaml.Node, offset int) *YamlNode {
}
}

func newYamlNodeWithParent(parent, node *yaml.Node, offset int) *YamlNode {
return &YamlNode{
Position: NewFilePosition(nodeLines(node, offset)),
Value: node.Value,
Comments: mergeComments(node),
}
}

func newYamlKeyValue(key, val *yaml.Node, offset int) *YamlKeyValue {
return &YamlKeyValue{
Key: newYamlNode(key, offset),
Value: newYamlNodeWithParent(key, val, offset),
Value: newYamlNode(val, offset),
}
}

Expand Down Expand Up @@ -209,7 +201,7 @@ func (pqle PromQLExpr) Lines() (lines []int) {
func newPromQLExpr(key, val *yaml.Node, offset int) *PromQLExpr {
expr := PromQLExpr{
Key: newYamlNode(key, offset),
Value: newYamlNodeWithParent(key, val, offset),
Value: newYamlNode(val, offset),
}

qlNode, err := DecodeExpr(val.Value)
Expand Down
2 changes: 1 addition & 1 deletion internal/promapi/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (c *queryCache) get(key uint64, endpoint string) (v any, ok bool) {

// Cache results if it was requested at least twice EVER - which means it's either
// popular and requested multiple times within a loop OR this cache key survives between loops.
func (c *queryCache) set(key uint64, val any, ttl time.Duration, endpoint string) {
func (c *queryCache) set(key uint64, val any, ttl time.Duration) {
c.mu.Lock()
defer c.mu.Unlock()

Expand Down
Loading

0 comments on commit f02d2be

Please sign in to comment.