add golangci-lint linter (#5499)

This commit is contained in:
Ondřej Benkovský
2022-07-10 20:06:33 +02:00
committed by GitHub
parent abc5ac8017
commit c2dbb7141a
104 changed files with 83 additions and 184 deletions

View File

@@ -180,7 +180,6 @@ func newEdns0VariableRule(mode, action, code, variable string) (*edns0VariableRu
// ruleData returns the data specified by the variable.
func (rule *edns0VariableRule) ruleData(ctx context.Context, state request.Request) ([]byte, error) {
switch rule.variable {
case queryName:
return []byte(state.QName()), nil

View File

@@ -367,7 +367,6 @@ func parseAnswerRules(name string, args []string) (auto bool, rules ResponseRule
if last == "" && args[arg] != AnswerMatch {
if last == "" {
return false, nil, fmt.Errorf("exceeded the number of arguments for a non-answer rule argument for %s rule", name)
}
return false, nil, fmt.Errorf("exceeded the number of arguments for %s answer rule for %s rule", last, name)
}

View File

@@ -33,7 +33,6 @@ func TestRewriteIllegalName(t *testing.T) {
}
func TestRewriteNamePrefixSuffix(t *testing.T) {
ctx, close := context.WithCancel(context.TODO())
defer close()
@@ -76,7 +75,6 @@ func TestRewriteNamePrefixSuffix(t *testing.T) {
}
func TestRewriteNameNoRewrite(t *testing.T) {
ctx, close := context.WithCancel(context.TODO())
defer close()
@@ -119,7 +117,6 @@ func TestRewriteNameNoRewrite(t *testing.T) {
}
func TestRewriteNamePrefixSuffixNoAutoAnswer(t *testing.T) {
ctx, close := context.WithCancel(context.TODO())
defer close()
@@ -162,7 +159,6 @@ func TestRewriteNamePrefixSuffixNoAutoAnswer(t *testing.T) {
}
func TestRewriteNamePrefixSuffixAutoAnswer(t *testing.T) {
ctx, close := context.WithCancel(context.TODO())
defer close()
@@ -211,7 +207,6 @@ func TestRewriteNamePrefixSuffixAutoAnswer(t *testing.T) {
}
func TestRewriteNameExactAnswer(t *testing.T) {
ctx, close := context.WithCancel(context.TODO())
defer close()
@@ -260,7 +255,6 @@ func TestRewriteNameExactAnswer(t *testing.T) {
}
func TestRewriteNameRegexAnswer(t *testing.T) {
ctx, close := context.WithCancel(context.TODO())
defer close()

View File

@@ -31,7 +31,6 @@ var tests = []struct {
}
func TestResponseReverter(t *testing.T) {
rules := []Rule{}
r, _ := newNameRule("stop", "regex", `(core)\.(dns)\.(rocks)`, "{2}.{1}.{3}", "answer", "name", `(dns)\.(core)\.(rocks)`, "{2}.{1}.{3}")
rules = append(rules, r)
@@ -98,7 +97,6 @@ var valueTests = []struct {
}
func TestValueResponseReverter(t *testing.T) {
rules := []Rule{}
r, err := newNameRule("stop", "regex", `(.*)\.domain\.uk`, "{1}.cluster.local", "answer", "name", `(.*)\.cluster\.local`, "{1}.domain.uk", "answer", "value", `(.*)\.cluster\.local`, "{1}.domain.uk")
if err != nil {

View File

@@ -8,7 +8,6 @@ import (
)
func TestParse(t *testing.T) {
tests := []struct {
inputFileRules string
shouldErr bool
@@ -49,5 +48,4 @@ func TestParse(t *testing.T) {
t.Errorf("Test %d got wrong error for invalid response rewrite: '%v'\n---\n%s", i, err.Error(), test.inputFileRules)
}
}
}

View File

@@ -9,7 +9,6 @@ import (
// ipToWire writes IP address to wire/binary format, 4 or 16 bytes depends on IPV4 or IPV6.
func ipToWire(family int, ipAddr string) ([]byte, error) {
switch family {
case 1:
return net.ParseIP(ipAddr).To4(), nil
@@ -28,7 +27,6 @@ func uint16ToWire(data uint16) []byte {
// portToWire writes port to wire/binary format, 2 bytes
func portToWire(portStr string) ([]byte, error) {
port, err := strconv.ParseUint(portStr, 10, 16)
if err != nil {
return nil, err