Skip to content

Commit

Permalink
.github/ci: Replace staticcheck with golang-ci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg committed Dec 8, 2021
1 parent 3110868 commit dc67485
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 37 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,14 @@ jobs:
go env GOARCH
go test -timeout 240s ./...
staticcheck:
name: staticcheck
golangci:
name: lint
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- uses: actions/setup-go@v2
with:
go-version: '^1.17.4'
- run: |
test -z "$(go fmt ./...)"
go vet ./...
export PATH=${PATH}:`go env GOPATH`/bin
go install honnef.co/go/tools/cmd/[email protected]
staticcheck ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v2

embeded:
name: embeded
Expand Down
13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
run:
deadline: 5m

linters:
disable-all: true
enable:
- gofmt
- goimports
- gosimple
- govet
- misspell
- staticcheck
- typecheck
6 changes: 3 additions & 3 deletions cmd/gobgp/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ func extractOrigin(args []string) ([]string, bgp.PathAttributeInterface, error)
break
}
}
return args, bgp.NewPathAttributeOrigin(uint8(typ)), nil
return args, bgp.NewPathAttributeOrigin(typ), nil
}

func toAs4Value(s string) (uint32, error) {
Expand Down Expand Up @@ -994,7 +994,7 @@ func newAsPath(aspath string) (bgp.PathAttributeInterface, error) {
if asn, err := toAs4Value(n); err != nil {
return nil, err
} else {
asNums = append(asNums, uint32(asn))
asNums = append(asNums, asn)
}
}
// Assumes "idx" is even, the given "segment" is of type AS_SEQUENCE,
Expand Down Expand Up @@ -1137,7 +1137,7 @@ func extractAigp(args []string) ([]string, bgp.PathAttributeInterface, error) {
if err != nil {
return nil, nil, err
}
aigp := bgp.NewPathAttributeAigp([]bgp.AigpTLVInterface{bgp.NewAigpTLVIgpMetric(uint64(metric))})
aigp := bgp.NewPathAttributeAigp([]bgp.AigpTLVInterface{bgp.NewAigpTLVIgpMetric(metric)})
return append(args[:idx], args[idx+3:]...), aigp, nil
default:
return nil, nil, fmt.Errorf("unknown aigp type: %s", typ)
Expand Down
2 changes: 1 addition & 1 deletion cmd/gobgp/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func showNeighborRib(r string, name string, args []string) error {
}
args = args[1:]
}
filter = []*api.TableLookupPrefix{&api.TableLookupPrefix{
filter = []*api.TableLookupPrefix{{
Prefix: target,
LookupOption: option,
},
Expand Down
16 changes: 8 additions & 8 deletions internal/pkg/table/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ func createPrefixSet(name string, prefix string, maskLength string) config.Prefi
ps := config.PrefixSet{
PrefixSetName: name,
PrefixList: []config.Prefix{
config.Prefix{
{
IpPrefix: prefix,
MasklengthRange: maskLength,
}},
Expand Down Expand Up @@ -3052,8 +3052,8 @@ func TestPrefixSetMatchV6LabeledwithV6Prefix(t *testing.T) {

func TestLargeCommunityMatchAction(t *testing.T) {
coms := []*bgp.LargeCommunity{
&bgp.LargeCommunity{ASN: 100, LocalData1: 100, LocalData2: 100},
&bgp.LargeCommunity{ASN: 100, LocalData1: 200, LocalData2: 200},
{ASN: 100, LocalData1: 100, LocalData2: 100},
{ASN: 100, LocalData1: 200, LocalData2: 200},
}
p := NewPath(nil, nil, false, []bgp.PathAttributeInterface{bgp.NewPathAttributeLargeCommunities(coms)}, time.Time{}, false)

Expand Down Expand Up @@ -3133,8 +3133,8 @@ func TestLargeCommunityMatchAction(t *testing.T) {

func TestLargeCommunitiesMatchClearAction(t *testing.T) {
coms := []*bgp.LargeCommunity{
&bgp.LargeCommunity{ASN: 100, LocalData1: 100, LocalData2: 100},
&bgp.LargeCommunity{ASN: 100, LocalData1: 200, LocalData2: 200},
{ASN: 100, LocalData1: 100, LocalData2: 100},
{ASN: 100, LocalData1: 200, LocalData2: 200},
}
p := NewPath(nil, nil, false, []bgp.PathAttributeInterface{bgp.NewPathAttributeLargeCommunities(coms)}, time.Time{}, false)

Expand Down Expand Up @@ -3193,17 +3193,17 @@ func TestAfiSafiInMatchPath(t *testing.T) {
func TestMultipleStatementPolicy(t *testing.T) {
r := NewRoutingPolicy(logger)
rp := config.RoutingPolicy{
PolicyDefinitions: []config.PolicyDefinition{config.PolicyDefinition{
PolicyDefinitions: []config.PolicyDefinition{{
Name: "p1",
Statements: []config.Statement{
config.Statement{
{
Actions: config.Actions{
BgpActions: config.BgpActions{
SetMed: "+100",
},
},
},
config.Statement{
{
Actions: config.Actions{
BgpActions: config.BgpActions{
SetLocalPref: 100,
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/zebra/zapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ func (c *Client) SupportMpls() bool {
// Note: frr3&4 have LABEL_MANAGER_CONNECT& GET_LABEL_CHUNK. However
// Routes will not be installed via zebra of frr3&4 after call these APIs.
if c.Version < 5 || c.SoftwareName == "frr4" {
return false // if frr4 or ealier are used
return false // if frr4 or earlier are used
}
return true // if frr5 or later are used
}
Expand Down Expand Up @@ -2329,7 +2329,7 @@ func (b *IPRouteBody) RouteFamily(logger log.Logger, version uint8, softwareName
}
safi := b.safi(logger, version, softwareName)
if safi == safiEvpn {
return bgp.RF_EVPN // sucess
return bgp.RF_EVPN // success
}
family := b.Prefix.Family
if family == syscall.AF_UNSPEC {
Expand All @@ -2353,7 +2353,7 @@ func (b *IPRouteBody) RouteFamily(logger log.Logger, version uint8, softwareName
"Safi": safi.String(),
"Rf": rf.String()})

return rf // sucess
return rf // success
}

// IsWithdraw is referred in zclient
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/zebra/zapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ package zebra

import (
"encoding/binary"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net"
"syscall"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_Header(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ func InitialConfig(ctx context.Context, bgpServer *server.BgpServer, newConfig *
if newConfig.Zebra.Config.Enabled {
tps := newConfig.Zebra.Config.RedistributeRouteTypeList
l := make([]string, 0, len(tps))
for _, t := range tps {
l = append(l, string(t))
}
l = append(l, tps...)
if err := bgpServer.EnableZebra(ctx, &api.EnableZebraRequest{
Url: newConfig.Zebra.Config.Url,
RouteTypes: l,
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ExampleInitialConfig() {
}
}

// ExampleUpdateConfig shows how UpdateConfig is used in conjuction with
// ExampleUpdateConfig shows how UpdateConfig is used in conjunction with
// InitialConfig.
func ExampleUpdateConfig() {
bgpServer := server.NewBgpServer()
Expand Down
12 changes: 6 additions & 6 deletions tools/config/example_toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ func main() {
},
},
Neighbors: []config.Neighbor{
config.Neighbor{
{
Config: config.NeighborConfig{
PeerAs: 12333,
AuthPassword: "apple",
NeighborAddress: "192.168.177.33",
},
AfiSafis: []config.AfiSafi{
config.AfiSafi{
{
Config: config.AfiSafiConfig{
AfiSafiName: "ipv4-unicast",
},
},
config.AfiSafi{
{
Config: config.AfiSafiConfig{
AfiSafiName: "ipv6-unicast",
},
Expand All @@ -44,15 +44,15 @@ func main() {
},
},

config.Neighbor{
{
Config: config.NeighborConfig{
PeerAs: 12334,
AuthPassword: "orange",
NeighborAddress: "192.168.177.32",
},
},

config.Neighbor{
{
Config: config.NeighborConfig{
PeerAs: 12335,
AuthPassword: "grape",
Expand Down Expand Up @@ -81,7 +81,7 @@ func policy() config.RoutingPolicy {
ps := config.PrefixSet{
PrefixSetName: "ps1",
PrefixList: []config.Prefix{
config.Prefix{
{
IpPrefix: "10.3.192.0/21",
MasklengthRange: "21..24",
}},
Expand Down

0 comments on commit dc67485

Please sign in to comment.