enable durationcheck, predeclared, unconvert, unused and wastedassign linters
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
3bc00017e3
commit
2fb0efe8a3
@ -10,6 +10,7 @@ issues:
|
|||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- contextcheck
|
- contextcheck
|
||||||
|
- durationcheck
|
||||||
- gci
|
- gci
|
||||||
- gocritic
|
- gocritic
|
||||||
- gofumpt
|
- gofumpt
|
||||||
@ -17,8 +18,12 @@ linters:
|
|||||||
- ineffassign
|
- ineffassign
|
||||||
- misspell
|
- misspell
|
||||||
- nonamedreturns
|
- nonamedreturns
|
||||||
|
- predeclared
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
|
- unconvert
|
||||||
|
- unused
|
||||||
|
- wastedassign
|
||||||
disable:
|
disable:
|
||||||
- errcheck
|
- errcheck
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ var _ = Describe("Echosvr", func() {
|
|||||||
It("connects successfully using echo client", func() {
|
It("connects successfully using echo client", func() {
|
||||||
Eventually(session.Out).Should(gbytes.Say("\n"))
|
Eventually(session.Out).Should(gbytes.Say("\n"))
|
||||||
serverAddress := strings.TrimSpace(string(session.Out.Contents()))
|
serverAddress := strings.TrimSpace(string(session.Out.Contents()))
|
||||||
fmt.Println("Server address", string(serverAddress))
|
fmt.Println("Server address", serverAddress)
|
||||||
|
|
||||||
cmd := exec.Command(clientBinaryPath, "-target", serverAddress, "-message", "hello")
|
cmd := exec.Command(clientBinaryPath, "-target", serverAddress, "-message", "hello")
|
||||||
clientSession, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
|
clientSession, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
|
||||||
|
@ -306,7 +306,7 @@ func (tc testCase) createCheckCmdArgs(targetNS ns.NetNS, config *Net, dataDir st
|
|||||||
ContainerID: fmt.Sprintf("dummy-%d", counter),
|
ContainerID: fmt.Sprintf("dummy-%d", counter),
|
||||||
Netns: targetNS.Path(),
|
Netns: targetNS.Path(),
|
||||||
IfName: IFNAME,
|
IfName: IFNAME,
|
||||||
StdinData: []byte(conf),
|
StdinData: conf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +125,9 @@ func createTBF(rateInBits, burstInBits uint64, linkIndex int) error {
|
|||||||
}
|
}
|
||||||
rateInBytes := rateInBits / 8
|
rateInBytes := rateInBits / 8
|
||||||
burstInBytes := burstInBits / 8
|
burstInBytes := burstInBits / 8
|
||||||
bufferInBytes := buffer(uint64(rateInBytes), uint32(burstInBytes))
|
bufferInBytes := buffer(rateInBytes, uint32(burstInBytes))
|
||||||
latency := latencyInUsec(latencyInMillis)
|
latency := latencyInUsec(latencyInMillis)
|
||||||
limitInBytes := limit(uint64(rateInBytes), latency, uint32(burstInBytes))
|
limitInBytes := limit(rateInBytes, latency, uint32(burstInBytes))
|
||||||
|
|
||||||
qdisc := &netlink.Tbf{
|
qdisc := &netlink.Tbf{
|
||||||
QdiscAttrs: netlink.QdiscAttrs{
|
QdiscAttrs: netlink.QdiscAttrs{
|
||||||
@ -135,9 +135,9 @@ func createTBF(rateInBits, burstInBits uint64, linkIndex int) error {
|
|||||||
Handle: netlink.MakeHandle(1, 0),
|
Handle: netlink.MakeHandle(1, 0),
|
||||||
Parent: netlink.HANDLE_ROOT,
|
Parent: netlink.HANDLE_ROOT,
|
||||||
},
|
},
|
||||||
Limit: uint32(limitInBytes),
|
Limit: limitInBytes,
|
||||||
Rate: uint64(rateInBytes),
|
Rate: rateInBytes,
|
||||||
Buffer: uint32(bufferInBytes),
|
Buffer: bufferInBytes,
|
||||||
}
|
}
|
||||||
err := netlink.QdiscAdd(qdisc)
|
err := netlink.QdiscAdd(qdisc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -147,7 +147,7 @@ func createTBF(rateInBits, burstInBits uint64, linkIndex int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func time2Tick(time uint32) uint32 {
|
func time2Tick(time uint32) uint32 {
|
||||||
return uint32(float64(time) * float64(netlink.TickInUsec()))
|
return uint32(float64(time) * netlink.TickInUsec())
|
||||||
}
|
}
|
||||||
|
|
||||||
func buffer(rate uint64, burst uint32) uint32 {
|
func buffer(rate uint64, burst uint32) uint32 {
|
||||||
|
@ -299,9 +299,9 @@ func cmdCheck(args *skel.CmdArgs) error {
|
|||||||
if bandwidth.IngressRate > 0 && bandwidth.IngressBurst > 0 {
|
if bandwidth.IngressRate > 0 && bandwidth.IngressBurst > 0 {
|
||||||
rateInBytes := bandwidth.IngressRate / 8
|
rateInBytes := bandwidth.IngressRate / 8
|
||||||
burstInBytes := bandwidth.IngressBurst / 8
|
burstInBytes := bandwidth.IngressBurst / 8
|
||||||
bufferInBytes := buffer(uint64(rateInBytes), uint32(burstInBytes))
|
bufferInBytes := buffer(rateInBytes, uint32(burstInBytes))
|
||||||
latency := latencyInUsec(latencyInMillis)
|
latency := latencyInUsec(latencyInMillis)
|
||||||
limitInBytes := limit(uint64(rateInBytes), latency, uint32(burstInBytes))
|
limitInBytes := limit(rateInBytes, latency, uint32(burstInBytes))
|
||||||
|
|
||||||
qdiscs, err := SafeQdiscList(link)
|
qdiscs, err := SafeQdiscList(link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -316,13 +316,13 @@ func cmdCheck(args *skel.CmdArgs) error {
|
|||||||
if !isTbf {
|
if !isTbf {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if tbf.Rate != uint64(rateInBytes) {
|
if tbf.Rate != rateInBytes {
|
||||||
return fmt.Errorf("Rate doesn't match")
|
return fmt.Errorf("Rate doesn't match")
|
||||||
}
|
}
|
||||||
if tbf.Limit != uint32(limitInBytes) {
|
if tbf.Limit != limitInBytes {
|
||||||
return fmt.Errorf("Limit doesn't match")
|
return fmt.Errorf("Limit doesn't match")
|
||||||
}
|
}
|
||||||
if tbf.Buffer != uint32(bufferInBytes) {
|
if tbf.Buffer != bufferInBytes {
|
||||||
return fmt.Errorf("Buffer doesn't match")
|
return fmt.Errorf("Buffer doesn't match")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,9 +331,9 @@ func cmdCheck(args *skel.CmdArgs) error {
|
|||||||
if bandwidth.EgressRate > 0 && bandwidth.EgressBurst > 0 {
|
if bandwidth.EgressRate > 0 && bandwidth.EgressBurst > 0 {
|
||||||
rateInBytes := bandwidth.EgressRate / 8
|
rateInBytes := bandwidth.EgressRate / 8
|
||||||
burstInBytes := bandwidth.EgressBurst / 8
|
burstInBytes := bandwidth.EgressBurst / 8
|
||||||
bufferInBytes := buffer(uint64(rateInBytes), uint32(burstInBytes))
|
bufferInBytes := buffer(rateInBytes, uint32(burstInBytes))
|
||||||
latency := latencyInUsec(latencyInMillis)
|
latency := latencyInUsec(latencyInMillis)
|
||||||
limitInBytes := limit(uint64(rateInBytes), latency, uint32(burstInBytes))
|
limitInBytes := limit(rateInBytes, latency, uint32(burstInBytes))
|
||||||
|
|
||||||
ifbDeviceName := getIfbDeviceName(bwConf.Name, args.ContainerID)
|
ifbDeviceName := getIfbDeviceName(bwConf.Name, args.ContainerID)
|
||||||
|
|
||||||
@ -355,13 +355,13 @@ func cmdCheck(args *skel.CmdArgs) error {
|
|||||||
if !isTbf {
|
if !isTbf {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if tbf.Rate != uint64(rateInBytes) {
|
if tbf.Rate != rateInBytes {
|
||||||
return fmt.Errorf("Rate doesn't match")
|
return fmt.Errorf("Rate doesn't match")
|
||||||
}
|
}
|
||||||
if tbf.Limit != uint32(limitInBytes) {
|
if tbf.Limit != limitInBytes {
|
||||||
return fmt.Errorf("Limit doesn't match")
|
return fmt.Errorf("Limit doesn't match")
|
||||||
}
|
}
|
||||||
if tbf.Buffer != uint32(bufferInBytes) {
|
if tbf.Buffer != bufferInBytes {
|
||||||
return fmt.Errorf("Buffer doesn't match")
|
return fmt.Errorf("Buffer doesn't match")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func spawnSessionDbus(wg *sync.WaitGroup) (string, *exec.Cmd) {
|
|||||||
// Wait for dbus-daemon to print the bus address
|
// Wait for dbus-daemon to print the bus address
|
||||||
bytes, err := bufio.NewReader(stdout).ReadString('\n')
|
bytes, err := bufio.NewReader(stdout).ReadString('\n')
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
busAddr := strings.TrimSpace(string(bytes))
|
busAddr := strings.TrimSpace(bytes)
|
||||||
Expect(strings.HasPrefix(busAddr, "unix:abstract")).To(BeTrue())
|
Expect(strings.HasPrefix(busAddr, "unix:abstract")).To(BeTrue())
|
||||||
|
|
||||||
var startWg sync.WaitGroup
|
var startWg sync.WaitGroup
|
||||||
@ -197,9 +197,9 @@ var _ = Describe("firewalld test", func() {
|
|||||||
ContainerID: "dummy",
|
ContainerID: "dummy",
|
||||||
Netns: targetNs.Path(),
|
Netns: targetNs.Path(),
|
||||||
IfName: ifname,
|
IfName: ifname,
|
||||||
StdinData: []byte(conf),
|
StdinData: conf,
|
||||||
}
|
}
|
||||||
_, _, err := testutils.CmdAdd(targetNs.Path(), args.ContainerID, ifname, []byte(conf), func() error {
|
_, _, err := testutils.CmdAdd(targetNs.Path(), args.ContainerID, ifname, conf, func() error {
|
||||||
return cmdAdd(args)
|
return cmdAdd(args)
|
||||||
})
|
})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
@ -223,9 +223,9 @@ var _ = Describe("firewalld test", func() {
|
|||||||
ContainerID: "dummy",
|
ContainerID: "dummy",
|
||||||
Netns: targetNs.Path(),
|
Netns: targetNs.Path(),
|
||||||
IfName: ifname,
|
IfName: ifname,
|
||||||
StdinData: []byte(conf),
|
StdinData: conf,
|
||||||
}
|
}
|
||||||
_, _, err := testutils.CmdAdd(targetNs.Path(), args.ContainerID, ifname, []byte(conf), func() error {
|
_, _, err := testutils.CmdAdd(targetNs.Path(), args.ContainerID, ifname, conf, func() error {
|
||||||
return cmdAdd(args)
|
return cmdAdd(args)
|
||||||
})
|
})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
@ -241,9 +241,9 @@ var _ = Describe("firewalld test", func() {
|
|||||||
ContainerID: "dummy",
|
ContainerID: "dummy",
|
||||||
Netns: targetNs.Path(),
|
Netns: targetNs.Path(),
|
||||||
IfName: ifname,
|
IfName: ifname,
|
||||||
StdinData: []byte(conf),
|
StdinData: conf,
|
||||||
}
|
}
|
||||||
r, _, err := testutils.CmdAdd(targetNs.Path(), args.ContainerID, ifname, []byte(conf), func() error {
|
r, _, err := testutils.CmdAdd(targetNs.Path(), args.ContainerID, ifname, conf, func() error {
|
||||||
return cmdAdd(args)
|
return cmdAdd(args)
|
||||||
})
|
})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
@ -265,7 +265,7 @@ var _ = Describe("firewalld test", func() {
|
|||||||
ContainerID: "dummy",
|
ContainerID: "dummy",
|
||||||
Netns: targetNs.Path(),
|
Netns: targetNs.Path(),
|
||||||
IfName: ifname,
|
IfName: ifname,
|
||||||
StdinData: []byte(conf),
|
StdinData: conf,
|
||||||
}
|
}
|
||||||
r, _, err := testutils.CmdAddWithArgs(args, func() error {
|
r, _, err := testutils.CmdAddWithArgs(args, func() error {
|
||||||
return cmdAdd(args)
|
return cmdAdd(args)
|
||||||
|
@ -256,7 +256,7 @@ func restoreBackup(ifName, containerID, backupPath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config := configToRestore{}
|
config := configToRestore{}
|
||||||
if err = json.Unmarshal([]byte(file), &config); err != nil {
|
if err = json.Unmarshal(file, &config); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ var _ = Describe("tuning plugin", func() {
|
|||||||
|
|
||||||
if testutils.SpecVersionHasCHECK(ver) {
|
if testutils.SpecVersionHasCHECK(ver) {
|
||||||
n := &TuningConf{}
|
n := &TuningConf{}
|
||||||
err = json.Unmarshal([]byte(conf), &n)
|
err = json.Unmarshal(conf, &n)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
||||||
@ -395,7 +395,7 @@ var _ = Describe("tuning plugin", func() {
|
|||||||
|
|
||||||
if testutils.SpecVersionHasCHECK(ver) {
|
if testutils.SpecVersionHasCHECK(ver) {
|
||||||
n := &TuningConf{}
|
n := &TuningConf{}
|
||||||
err = json.Unmarshal([]byte(conf), &n)
|
err = json.Unmarshal(conf, &n)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
||||||
@ -541,7 +541,7 @@ var _ = Describe("tuning plugin", func() {
|
|||||||
|
|
||||||
if testutils.SpecVersionHasCHECK(ver) {
|
if testutils.SpecVersionHasCHECK(ver) {
|
||||||
n := &TuningConf{}
|
n := &TuningConf{}
|
||||||
err = json.Unmarshal([]byte(conf), &n)
|
err = json.Unmarshal(conf, &n)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
||||||
@ -687,7 +687,7 @@ var _ = Describe("tuning plugin", func() {
|
|||||||
|
|
||||||
if testutils.SpecVersionHasCHECK(ver) {
|
if testutils.SpecVersionHasCHECK(ver) {
|
||||||
n := &TuningConf{}
|
n := &TuningConf{}
|
||||||
err = json.Unmarshal([]byte(conf), &n)
|
err = json.Unmarshal(conf, &n)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
||||||
@ -839,7 +839,7 @@ var _ = Describe("tuning plugin", func() {
|
|||||||
|
|
||||||
if testutils.SpecVersionHasCHECK(ver) {
|
if testutils.SpecVersionHasCHECK(ver) {
|
||||||
n := &TuningConf{}
|
n := &TuningConf{}
|
||||||
err = json.Unmarshal([]byte(conf), &n)
|
err = json.Unmarshal(conf, &n)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
||||||
@ -918,7 +918,7 @@ var _ = Describe("tuning plugin", func() {
|
|||||||
|
|
||||||
if testutils.SpecVersionHasCHECK(ver) {
|
if testutils.SpecVersionHasCHECK(ver) {
|
||||||
n := &TuningConf{}
|
n := &TuningConf{}
|
||||||
err = json.Unmarshal([]byte(conf), &n)
|
err = json.Unmarshal(conf, &n)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
_, confString, err := buildOneConfig("testConfig", ver, n, r)
|
||||||
|
@ -587,7 +587,7 @@ var _ = Describe("vrf plugin", func() {
|
|||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
cniVersion := "0.4.0"
|
cniVersion := "0.4.0"
|
||||||
n := &VRFNetConf{}
|
n := &VRFNetConf{}
|
||||||
err = json.Unmarshal([]byte(conf), &n)
|
err = json.Unmarshal(conf, &n)
|
||||||
_, confString, err := buildOneConfig("testConfig", cniVersion, n, prevRes)
|
_, confString, err := buildOneConfig("testConfig", cniVersion, n, prevRes)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user