mirror of
https://github.com/coredns/coredns.git
synced 2025-08-05 22:07:00 +02:00
chore: enable early-return and superfluous-else from revive (#7129)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
ddb74cdcf4
commit
186e4a1dbb
@ -1,4 +1,9 @@
|
|||||||
version: "2"
|
version: "2"
|
||||||
|
|
||||||
|
issues:
|
||||||
|
max-issues-per-linter: 0
|
||||||
|
max-same-issues: 0
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
default: none
|
default: none
|
||||||
enable:
|
enable:
|
||||||
@ -23,16 +28,82 @@ linters:
|
|||||||
- common-false-positives
|
- common-false-positives
|
||||||
- legacy
|
- legacy
|
||||||
- std-error-handling
|
- std-error-handling
|
||||||
paths:
|
settings:
|
||||||
- third_party$
|
revive:
|
||||||
- builtin$
|
rules:
|
||||||
- examples$
|
- name: blank-imports
|
||||||
|
|
||||||
|
- name: context-as-argument
|
||||||
|
disabled: true
|
||||||
|
arguments:
|
||||||
|
- allowTypesBefore: "*testing.T"
|
||||||
|
|
||||||
|
- name: context-keys-type
|
||||||
|
|
||||||
|
- name: dot-imports
|
||||||
|
|
||||||
|
- name: early-return
|
||||||
|
arguments:
|
||||||
|
- "preserveScope"
|
||||||
|
|
||||||
|
- name: empty-block
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
- name: error-naming
|
||||||
|
|
||||||
|
- name: error-return
|
||||||
|
|
||||||
|
- name: error-strings
|
||||||
|
|
||||||
|
- name: errorf
|
||||||
|
|
||||||
|
- name: increment-decrement
|
||||||
|
|
||||||
|
- name: indent-error-flow
|
||||||
|
arguments:
|
||||||
|
- "preserveScope"
|
||||||
|
|
||||||
|
- name: range
|
||||||
|
|
||||||
|
- name: receiver-naming
|
||||||
|
|
||||||
|
- name: redefines-builtin-id
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
- name: superfluous-else
|
||||||
|
arguments:
|
||||||
|
- "preserveScope"
|
||||||
|
|
||||||
|
- name: time-naming
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
- name: unexported-return
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
- name: unnecessary-stmt
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
- name: unreachable-code
|
||||||
|
|
||||||
|
- name: unused-parameter
|
||||||
|
disabled: true
|
||||||
|
arguments:
|
||||||
|
- allowRegex: "^_"
|
||||||
|
|
||||||
|
- name: use-any
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
- name: var-declaration
|
||||||
|
|
||||||
|
- name: var-naming
|
||||||
|
disabled: true
|
||||||
|
arguments:
|
||||||
|
- ["ID"]
|
||||||
|
- ["VM"]
|
||||||
|
- - upperCaseConst: true
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
enable:
|
enable:
|
||||||
- gofmt
|
- gofmt
|
||||||
exclusions:
|
exclusions:
|
||||||
generated: lax
|
generated: lax
|
||||||
paths:
|
|
||||||
- third_party$
|
|
||||||
- builtin$
|
|
||||||
- examples$
|
|
||||||
|
@ -118,11 +118,10 @@ func autoParse(c *caddy.Controller) (Auto, error) {
|
|||||||
}
|
}
|
||||||
_, err := os.Stat(a.directory)
|
_, err := os.Stat(a.directory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
log.Warningf("Directory does not exist: %s", a.directory)
|
|
||||||
} else {
|
|
||||||
return a, c.Errf("Unable to access root path '%s': %v", a.directory, err)
|
return a, c.Errf("Unable to access root path '%s': %v", a.directory, err)
|
||||||
}
|
}
|
||||||
|
log.Warningf("Directory does not exist: %s", a.directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// regexp template
|
// regexp template
|
||||||
|
@ -149,12 +149,11 @@ func split255(s string) []string {
|
|||||||
sx := []string{}
|
sx := []string{}
|
||||||
p, i := 0, 255
|
p, i := 0, 255
|
||||||
for {
|
for {
|
||||||
if i <= len(s) {
|
if i > len(s) {
|
||||||
sx = append(sx, s[p:i])
|
|
||||||
} else {
|
|
||||||
sx = append(sx, s[p:])
|
sx = append(sx, s[p:])
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
sx = append(sx, s[p:i])
|
||||||
p, i = p+255, i+255
|
p, i = p+255, i+255
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,11 +96,10 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
|
|||||||
}
|
}
|
||||||
s, err := os.Stat(h.path)
|
s, err := os.Stat(h.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
log.Warningf("File does not exist: %s", h.path)
|
|
||||||
} else {
|
|
||||||
return h, c.Errf("unable to access hosts file '%s': %v", h.path, err)
|
return h, c.Errf("unable to access hosts file '%s': %v", h.path, err)
|
||||||
}
|
}
|
||||||
|
log.Warningf("File does not exist: %s", h.path)
|
||||||
}
|
}
|
||||||
if s != nil && s.IsDir() {
|
if s != nil && s.IsDir() {
|
||||||
log.Warningf("Hosts file %q is a directory", h.path)
|
log.Warningf("Hosts file %q is a directory", h.path)
|
||||||
|
@ -127,18 +127,17 @@ func (k *Kubernetes) External(state request.Request, headless bool) ([]msg.Servi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
} else {
|
}
|
||||||
for _, ip := range svc.ExternalIPs {
|
for _, ip := range svc.ExternalIPs {
|
||||||
for _, p := range svc.Ports {
|
for _, p := range svc.Ports {
|
||||||
if !(matchPortAndProtocol(port, p.Name, protocol, string(p.Protocol))) {
|
if !(matchPortAndProtocol(port, p.Name, protocol, string(p.Protocol))) {
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
rcode = dns.RcodeSuccess
|
|
||||||
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
|
|
||||||
s.Key = strings.Join([]string{zonePath, svc.Namespace, svc.Name}, "/")
|
|
||||||
|
|
||||||
services = append(services, s)
|
|
||||||
}
|
}
|
||||||
|
rcode = dns.RcodeSuccess
|
||||||
|
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
|
||||||
|
s.Key = strings.Join([]string{zonePath, svc.Namespace, svc.Name}, "/")
|
||||||
|
|
||||||
|
services = append(services, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,16 +194,15 @@ func (k *Kubernetes) ExternalServices(zone string, headless bool) (services []ms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
} else {
|
}
|
||||||
for _, ip := range svc.ExternalIPs {
|
for _, ip := range svc.ExternalIPs {
|
||||||
for _, p := range svc.Ports {
|
for _, p := range svc.Ports {
|
||||||
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
|
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
|
||||||
s.Key = strings.Join([]string{zonePath, svc.Namespace, svc.Name}, "/")
|
s.Key = strings.Join([]string{zonePath, svc.Namespace, svc.Name}, "/")
|
||||||
services = append(services, s)
|
services = append(services, s)
|
||||||
s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+p.Name)), "/")
|
s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+p.Name)), "/")
|
||||||
s.TargetStrip = 2
|
s.TargetStrip = 2
|
||||||
services = append(services, s)
|
services = append(services, s)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,9 +212,8 @@ func ParseStanza(c *caddy.Controller) (*Kubernetes, error) {
|
|||||||
if ignore == "empty_service" {
|
if ignore == "empty_service" {
|
||||||
k8s.opts.ignoreEmptyService = true
|
k8s.opts.ignoreEmptyService = true
|
||||||
continue
|
continue
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("unable to parse ignore value: '%v'", ignore)
|
|
||||||
}
|
}
|
||||||
|
return nil, fmt.Errorf("unable to parse ignore value: '%v'", ignore)
|
||||||
}
|
}
|
||||||
case "kubeconfig":
|
case "kubeconfig":
|
||||||
args := c.RemainingArgs()
|
args := c.RemainingArgs()
|
||||||
|
@ -23,15 +23,14 @@ func TransferIn(c *caddy.Controller) (froms []string, err error) {
|
|||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
}
|
}
|
||||||
for i := range froms {
|
for i := range froms {
|
||||||
if froms[i] != "*" {
|
if froms[i] == "*" {
|
||||||
normalized, err := HostPort(froms[i], transport.Port)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
froms[i] = normalized
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("can't use '*' in transfer from")
|
return nil, fmt.Errorf("can't use '*' in transfer from")
|
||||||
}
|
}
|
||||||
|
normalized, err := HostPort(froms[i], transport.Port)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
froms[i] = normalized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return froms, nil
|
return froms, nil
|
||||||
|
@ -26,13 +26,12 @@ func setup(c *caddy.Controller) error {
|
|||||||
// Check if root path exists
|
// Check if root path exists
|
||||||
_, err := os.Stat(config.Root)
|
_, err := os.Stat(config.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
// Allow this, because the folder might appear later.
|
|
||||||
// But make sure the user knows!
|
|
||||||
log.Warningf("Root path does not exist: %s", config.Root)
|
|
||||||
} else {
|
|
||||||
return plugin.Error("root", c.Errf("unable to access root path '%s': %v", config.Root, err))
|
return plugin.Error("root", c.Errf("unable to access root path '%s': %v", config.Root, err))
|
||||||
}
|
}
|
||||||
|
// Allow this, because the folder might appear later.
|
||||||
|
// But make sure the user knows!
|
||||||
|
log.Warningf("Root path does not exist: %s", config.Root)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user