lint(revive): fix unnecessary-stmt violations (#7978)

This commit is contained in:
Ville Vesilehto
2026-03-30 03:02:03 +03:00
committed by GitHub
parent 867cd8fd6b
commit 6af8fd46fe
5 changed files with 45 additions and 46 deletions

View File

@@ -99,7 +99,6 @@ linters:
disabled: true disabled: true
- name: unnecessary-stmt - name: unnecessary-stmt
disabled: true
- name: unreachable-code - name: unreachable-code
disabled: true disabled: true

View File

@@ -65,7 +65,6 @@ func roundRobin(in []dns.RR) []dns.RR {
func roundRobinShuffle(records []dns.RR) { func roundRobinShuffle(records []dns.RR) {
switch l := len(records); l { switch l := len(records); l {
case 0, 1: case 0, 1:
break
case 2: case 2:
if dns.Id()%2 == 0 { if dns.Id()%2 == 0 {
records[0], records[1] = records[1], records[0] records[0], records[1] = records[1], records[0]

View File

@@ -90,8 +90,7 @@ func parse(c *caddy.Controller) (string, monitorType, error) {
} }
for c.NextBlock() { for c.NextBlock() {
switch c.Val() { if c.Val() == "monitor" {
case "monitor":
args := c.RemainingArgs() args := c.RemainingArgs()
if len(args) != 1 { if len(args) != 1 {
return "", "", c.ArgErr() return "", "", c.ArgErr()

View File

@@ -69,12 +69,18 @@ func (r *cnameTargetRule) getFromAndToTarget(inputCName string) (from string, to
func (r *cnameTargetRuleWithReqState) RewriteResponse(res *dns.Msg, rr dns.RR) { func (r *cnameTargetRuleWithReqState) RewriteResponse(res *dns.Msg, rr dns.RR) {
// logic to rewrite the cname target of dns response // logic to rewrite the cname target of dns response
switch rr.Header().Rrtype { if rr.Header().Rrtype != dns.TypeCNAME {
case dns.TypeCNAME: return
}
// rename the target of the cname response // rename the target of the cname response
if cname, ok := rr.(*dns.CNAME); ok { cname, ok := rr.(*dns.CNAME)
if !ok {
return
}
fromTarget, toTarget := r.rule.getFromAndToTarget(cname.Target) fromTarget, toTarget := r.rule.getFromAndToTarget(cname.Target)
if cname.Target == fromTarget { if cname.Target != fromTarget {
return
}
// create upstream request with the new target with the same qtype // create upstream request with the new target with the same qtype
r.state.Req.Question[0].Name = toTarget r.state.Req.Question[0].Name = toTarget
// upRes can be nil if the internal query path didn't write a response // upRes can be nil if the internal query path didn't write a response
@@ -110,9 +116,6 @@ func (r *cnameTargetRuleWithReqState) RewriteResponse(res *dns.Msg, rr dns.RR) {
// if not propagated, the truncated response might get cached, // if not propagated, the truncated response might get cached,
// and it will be impossible to resolve the full response // and it will be impossible to resolve the full response
res.Truncated = upRes.Truncated res.Truncated = upRes.Truncated
}
}
}
} }
func newCNAMERule(nextAction string, args ...string) (Rule, error) { func newCNAMERule(nextAction string, args ...string) (Rule, error) {

View File

@@ -133,8 +133,7 @@ func resign(rd io.Reader, now time.Time) (why error) {
i := 0 i := 0
for rr, ok := zp.Next(); ok; rr, ok = zp.Next() { for rr, ok := zp.Next(); ok; rr, ok = zp.Next() {
switch x := rr.(type) { if x, ok := rr.(*dns.RRSIG); ok {
case *dns.RRSIG:
if x.TypeCovered != dns.TypeSOA { if x.TypeCovered != dns.TypeSOA {
continue continue
} }