mirror of
https://github.com/coredns/coredns.git
synced 2026-04-05 11:45:33 -04:00
lint(revive): fix unnecessary-stmt violations (#7978)
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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]
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -111,9 +117,6 @@ func (r *cnameTargetRuleWithReqState) RewriteResponse(res *dns.Msg, rr dns.RR) {
|
|||||||
// 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) {
|
||||||
var rewriteType string
|
var rewriteType string
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user