Skip to content

Commit

Permalink
Merge pull request ciao-project#1348 from rbradford/add-more-linters
Browse files Browse the repository at this point in the history
Add more linting coverage to ciao
  • Loading branch information
Mark Ryan authored Jul 19, 2017
2 parents d8d447f + f92f9bf commit 763e626
Show file tree
Hide file tree
Showing 22 changed files with 14 additions and 155 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ script:
- sudo docker pull debian
- sudo ip link add testdummy type dummy
- sudo ip addr add 198.51.100.1/24 dev testdummy
- gometalinter.v1 --tests --vendor --disable-all --enable=misspell --enable=vet --enable=ineffassign --enable=gofmt --enable=gocyclo --cyclo-over=15 --enable=golint --enable=deadcode ./...
- gometalinter.v1 --deadline=5m --tests --vendor --disable-all --enable=misspell --enable=vet --enable=ineffassign --enable=gofmt --enable=gocyclo --cyclo-over=15 --enable=golint --enable=deadcode --enable=varcheck --enable=structcheck ./...
- cd _release/bat
- gometalinter.v1 --tests --vendor --disable-all --enable=misspell --enable=vet --enable=ineffassign --enable=gofmt --enable=gocyclo --cyclo-over=15 --enable=golint --enable=deadcode ./...
- gometalinter.v1 --deadline=5m --tests --vendor --disable-all --enable=misspell --enable=vet --enable=ineffassign --enable=gofmt --enable=gocyclo --cyclo-over=15 --enable=golint --enable=deadcode --enable=varcheck --enable=structcheck ./...
- cd ../..
- sudo mkdir -p /var/lib/ciao/instances
- sudo mkdir -p /var/lib/ciao/data/controller/workloads
Expand Down
4 changes: 1 addition & 3 deletions ciao-cli/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ func (cmd *eventListCommand) run(args []string) error {
}

type eventDeleteCommand struct {
Flag flag.FlagSet
all bool
tenant string
Flag flag.FlagSet
}

func (cmd *eventDeleteCommand) usage(...string) {
Expand Down
1 change: 0 additions & 1 deletion ciao-cli/external_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ type poolAddCommand struct {
Flag flag.FlagSet
name string
subnet string
ips []string
}

func (cmd *poolAddCommand) usage(...string) {
Expand Down
2 changes: 0 additions & 2 deletions ciao-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ var scopedToken string
const openstackComputePort = 8774
const openstackComputeVersion = "v2.1"

type action uint8

func infof(format string, args ...interface{}) {
if glog.V(1) {
glog.InfoDepth(1, fmt.Sprintf("ciao-cli INFO: "+format, args...))
Expand Down
1 change: 0 additions & 1 deletion ciao-cli/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type nodeListCommand struct {
network bool
all bool
cnci bool
nodeID bool
template string
}

Expand Down
16 changes: 1 addition & 15 deletions ciao-controller/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,9 @@ func errorResponse(err error) APIResponse {
type pagerFilterType uint8

const (
none pagerFilterType = 0
statusFilter = 0x2
none pagerFilterType = 0
)

type pager interface {
filter(filterType pagerFilterType, filter string, item interface{}) bool
nextPage(filterType pagerFilterType, filter string, r *http.Request) ([]byte, error)
}

func pagerQueryParse(r *http.Request) (int, int, string) {
values := r.URL.Query()
limit := 0
Expand Down Expand Up @@ -133,10 +127,6 @@ func (pager *nodePager) getNodes(filterType pagerFilterType, filter string, node
return computeNodes, nil
}

func (pager *nodePager) filter(filterType pagerFilterType, filter string, node types.CiaoNode) bool {
return false
}

func (pager *nodePager) nextPage(filterType pagerFilterType, filter string, r *http.Request) (types.CiaoNodes, error) {
limit, offset, lastSeen := pagerQueryParse(r)

Expand Down Expand Up @@ -195,10 +185,6 @@ func (pager *nodeServerPager) getNodeServers(filterType pagerFilterType, filter
return servers, nil
}

func (pager *nodeServerPager) filter(filterType pagerFilterType, filter string, instance types.CiaoServerStats) bool {
return false
}

func (pager *nodeServerPager) nextPage(filterType pagerFilterType, filter string, r *http.Request) (types.CiaoServersStats, error) {
limit, offset, lastSeen := pagerQueryParse(r)

Expand Down
6 changes: 0 additions & 6 deletions ciao-controller/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"net/http"
"net/http/httptest"
"os"
"testing"

"github.com/01org/ciao/ciao-controller/types"
Expand All @@ -36,11 +35,6 @@ type test struct {
expectedResponse string
}

func myHostname() string {
host, _ := os.Hostname()
return host
}

var tests = []test{
{
"GET",
Expand Down
1 change: 0 additions & 1 deletion ciao-controller/client_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
)

type ssntpClientWrapper struct {
ctl *controller
name string
realClient controllerClient

Expand Down
1 change: 0 additions & 1 deletion ciao-controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,6 @@ func TestMapAddressNoPool(t *testing.T) {
}
}

var testClients []*testutil.SsntpTestClient
var ctl *controller
var server *testutil.SsntpTestServer
var wrappedClient *ssntpClientWrapper
Expand Down
1 change: 0 additions & 1 deletion ciao-image/datastore/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
)

var mountPoint = "/tmp"
var metaDsTables = []string{"images"}
var dbDir = "/tmp"
var dbFile = "ciao-image.db"
var testImageID = "12345678-1234-5678-1234-567812345678"
Expand Down
64 changes: 0 additions & 64 deletions ciao-launcher/qemu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,70 +28,6 @@ import (
"time"
)

var imageInfoTestGood = `
image: /var/lib/ciao/images/clear-8780-cloud.img
file format: qcow2
virtual size: 865M (907018240 bytes)
disk size: 113M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
`

var imageInfoTestMissingBytes = `
image: /var/lib/ciao/images/clear-8780-cloud.img
file format: qcow2
virtual size: 865M
disk size: 113M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
`

var imageInfoTestMissingLine = `
image: /var/lib/ciao/images/clear-8780-cloud.img
file format: qcow2
disk size: 113M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
`

var imageInfoTooBig = `
image: /var/lib/ciao/images/clear-8780-cloud.img
file format: qcow2
virtual size: 18,446,744,073,710M (18446744073709551615 bytes)
disk size: 113M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
`

var imageInfoBadBytes = `
image: /var/lib/ciao/images/clear-8780-cloud.img
file format: qcow2
virtual size: 865M (9aaaa07018240 bytes)
disk size: 113M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
`

func genQEMUParams(networkParams []string) []string {
baseParams := []string{
"-drive",
Expand Down
1 change: 0 additions & 1 deletion configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const invalidURI = "file://%z invalid uri with spaces"
const emptyPathURI = "file://"

const keystoneURL = "http://keystone.example.com"
const glanceURL = "http://glance.example.com"
const computeNet = "192.168.1.0/24"
const mgmtNet = "192.168.1.0/24"
const storageURI = "/etc/ciao/configuration.yaml"
Expand Down
1 change: 0 additions & 1 deletion networking/ciao-cnci-agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ type agentClient struct {
ssntpConn
db *cnciDatabase
cmdCh chan *cmdWrapper
netCh chan struct{} //Used to signal physical network changes
}

func (client *agentClient) DisconnectNotify() {
Expand Down
2 changes: 0 additions & 2 deletions networking/ciao-cnci-agent/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ func initNetwork(cancelCh <-chan os.Signal) error {
}

func unmarshallSubnetParams(cmd *payloads.TenantAddedEvent) (*net.IPNet, int, net.IP, error) {
const maxKey = ^uint32(0)

_, snet, err := net.ParseCIDR(cmd.TenantSubnet)
if err != nil {
return nil, 0, nil, errors.Wrapf(err, "invalid Remote subnet")
Expand Down
16 changes: 0 additions & 16 deletions networking/libsnnet/tests/parallel/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,22 +368,6 @@ func dockerNetDelete(t *testing.T, subnetID string) error {
return err
}

func dockerNetList(t *testing.T) error {
assert := assert.New(t)
defer logTime(t, time.Now(), "dockerNetList")
out, err := exec.Command("docker", "network", "ls").CombinedOutput()
assert.Nil(err, string(out))
return err
}

func dockerNetInfo(t *testing.T, subnetID string) error {
assert := assert.New(t)
defer logTime(t, time.Now(), "dockerNetInfo")
out, err := exec.Command("docker", "network", "inspect", subnetID).CombinedOutput()
assert.Nil(err, string(out))
return err
}

type dockerNetType int

const (
Expand Down
7 changes: 0 additions & 7 deletions openstack/compute/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,8 @@ type pagerFilterType uint8
const (
none pagerFilterType = iota
flavorFilter
limit
marker
)

type pager interface {
filter(filterType pagerFilterType, filter string, item interface{}) bool
nextPage(filterType pagerFilterType, filter string, r *http.Request) ([]byte, error)
}

type serverPager struct {
servers []ServerDetails
}
Expand Down
6 changes: 0 additions & 6 deletions openstack/compute/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"bytes"
"net/http"
"net/http/httptest"
"os"
"testing"
)

Expand All @@ -31,11 +30,6 @@ type test struct {
expectedResponse string
}

func myHostname() string {
host, _ := os.Hostname()
return host
}

var tests = []test{
{
"POST",
Expand Down
3 changes: 1 addition & 2 deletions qemu/qmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ type QMPEvent struct {
}

type qmpResult struct {
err error
data map[string]interface{}
err error
}

type qmpCommand struct {
Expand Down
27 changes: 9 additions & 18 deletions qemu/qmp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ import (
)

const (
microStr = "50"
minorStr = "6"
majorStr = "2"
micro = 50
minor = 6
major = 2
cap1 = "one"
cap2 = "two"
qmpHello = `{ "QMP": { "version": { "qemu": { "micro": ` + microStr + `, "minor": ` + minorStr + `, "major": ` + majorStr + ` }, "package": ""}, "capabilities": ["` + cap1 + `","` + cap2 + `"]}}` + "\n"
qmpSuccess = `{ "return": {}}` + "\n"
qmpFailure = `{ "error": {}}` + "\n"
microStr = "50"
minorStr = "6"
majorStr = "2"
micro = 50
minor = 6
major = 2
cap1 = "one"
cap2 = "two"
qmpHello = `{ "QMP": { "version": { "qemu": { "micro": ` + microStr + `, "minor": ` + minorStr + `, "major": ` + majorStr + ` }, "package": ""}, "capabilities": ["` + cap1 + `","` + cap2 + `"]}}` + "\n"
)

type qmpTestLogger struct{}
Expand Down Expand Up @@ -491,13 +489,6 @@ func TestQMPDeviceDel(t *testing.T) {
// The device_del command should timeout after 1 second and the QMP loop
// should exit gracefully.
func TestQMPDeviceDelTimeout(t *testing.T) {
const (
seconds = 1352167040730
microsecondsEv1 = 123456
device = "device_" + testutil.VolumeUUID
path = "/dev/rbd0"
)

var wg sync.WaitGroup
connectedCh := make(chan *QMPVersion)
disconnectedCh := make(chan struct{})
Expand Down
1 change: 0 additions & 1 deletion ssntp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ type Server struct {
stopped boolFlag
stoppedChan chan struct{}
role Role
roleVerify bool
clientWg sync.WaitGroup

forwardRules frameForward
Expand Down
3 changes: 0 additions & 3 deletions ssntp/ssntp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ type ssntpClient struct {
cmdTracedChannel chan string
cmdDurationChannel chan time.Duration
cmdDumpChannel chan struct{}
staTracedChannel chan string
evtTracedChannel chan string
errTracedChannel chan string
}

func (client *ssntpClient) ConnectNotify() {
Expand Down
1 change: 0 additions & 1 deletion testutil/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type SsntpTestClient struct {
Name string
instances []payloads.InstanceStat
instancesLock *sync.Mutex
ticker *time.Ticker
UUID string
Role ssntp.Role
StartFail bool
Expand Down

0 comments on commit 763e626

Please sign in to comment.