summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorImcom Jin <jinyu.bjut@gmail.com>2021-10-18 12:43:54 +0800
committerImcom Jin <jinyu.bjut@gmail.com>2021-10-18 12:43:54 +0800
commit313b5cf02cb225204372ced27dea8ab3b2fd3315 (patch)
tree5183501246878b31ecae3ef60efafcc75c6fa3e8
parent1684b45610ddd115762da1a154e8577a903f2cfe (diff)
chore: fix linting ineffassign and redundant type from array, slice, or map composite literal
-rw-r--r--pkg/server/fsm.go3
-rw-r--r--pkg/server/server_test.go12
2 files changed, 8 insertions, 7 deletions
diff --git a/pkg/server/fsm.go b/pkg/server/fsm.go
index fedf3018..a42ee910 100644
--- a/pkg/server/fsm.go
+++ b/pkg/server/fsm.go
@@ -873,7 +873,8 @@ func (h *fsmHandler) afiSafiDisable(rf bgp.RouteFamily) string {
}
func (h *fsmHandler) handlingError(m *bgp.BGPMessage, e error, useRevisedError bool) bgp.ErrorHandling {
- handling := bgp.ERROR_HANDLING_NONE
+ // ineffectual assignment to handling (ineffassign)
+ var handling bgp.ErrorHandling
if m.Header.Type == bgp.BGP_MSG_UPDATE && useRevisedError {
factor := e.(*bgp.MessageError)
handling = factor.ErrorHandling
diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go
index 24dcdf95..5220663b 100644
--- a/pkg/server/server_test.go
+++ b/pkg/server/server_test.go
@@ -112,7 +112,7 @@ func TestModPolicyAssign(t *testing.T) {
}
}
- r := f([]*config.PolicyDefinition{&config.PolicyDefinition{Name: "p1"}, &config.PolicyDefinition{Name: "p2"}, &config.PolicyDefinition{Name: "p3"}})
+ r := f([]*config.PolicyDefinition{{Name: "p1"}, {Name: "p2"}, {Name: "p3"}})
r.Direction = api.PolicyDirection_IMPORT
r.DefaultAction = api.RouteAction_ACCEPT
r.Name = table.GLOBAL_RIB_NAME
@@ -130,7 +130,7 @@ func TestModPolicyAssign(t *testing.T) {
assert.Nil(err)
assert.Equal(len(ps[0].Policies), 3)
- r = f([]*config.PolicyDefinition{&config.PolicyDefinition{Name: "p1"}})
+ r = f([]*config.PolicyDefinition{{Name: "p1"}})
r.Direction = api.PolicyDirection_IMPORT
r.DefaultAction = api.RouteAction_ACCEPT
r.Name = table.GLOBAL_RIB_NAME
@@ -187,7 +187,7 @@ func TestListPolicyAssignment(t *testing.T) {
Direction: api.PolicyDirection_IMPORT,
DefaultAction: api.RouteAction_ACCEPT,
Name: addr,
- Policies: []*api.Policy{&api.Policy{Name: fmt.Sprintf("p%d", i)}},
+ Policies: []*api.Policy{{Name: fmt.Sprintf("p%d", i)}},
}
err = s.AddPolicyAssignment(context.Background(), &api.AddPolicyAssignmentRequest{Assignment: pa})
assert.Nil(err)
@@ -243,7 +243,7 @@ func TestListPathEnableFiltered(test *testing.T) {
DefinedType: api.DefinedType_PREFIX,
Name: "d1",
Prefixes: []*api.Prefix{
- &api.Prefix{
+ {
IpPrefix: "10.1.0.0/24",
MaskLengthMax: 24,
MaskLengthMin: 24,
@@ -384,7 +384,7 @@ func TestListPathEnableFiltered(test *testing.T) {
DefinedType: api.DefinedType_PREFIX,
Name: "d2",
Prefixes: []*api.Prefix{
- &api.Prefix{
+ {
IpPrefix: "10.3.0.0/24",
MaskLengthMax: 24,
MaskLengthMin: 24,
@@ -835,7 +835,7 @@ func TestFilterpathWithRejectPolicy(t *testing.T) {
p, _ := table.NewPolicy(policy)
p2.policy.AddPolicy(p, false)
policies := []*config.PolicyDefinition{
- &config.PolicyDefinition{
+ {
Name: "policy1",
},
}