From ec87781956d8235f219089d6f0c6afed4e8ea4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre-Xavier=20Labont=C3=A9-Lamoureux?= Date: Tue, 11 Oct 2016 13:31:29 -0400 Subject: [PATCH] test: Tokens should always have a colon --- etcd/etcd.go | 18 +++++++++--------- pgraph/pgraph.go | 2 +- recwatch/recwatch.go | 6 +++--- resources/exec.go | 6 +++--- resources/file.go | 2 +- resources/msg.go | 2 +- resources/resources.go | 6 +++--- resources/svc.go | 6 +++--- test/test-govet.sh | 1 + 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/etcd/etcd.go b/etcd/etcd.go index 8fcef9dd..b55b9219 100644 --- a/etcd/etcd.go +++ b/etcd/etcd.go @@ -1086,7 +1086,7 @@ func (obj *EmbdEtcd) rawAddWatcher(ctx context.Context, aw *AW) (func(), error) } if err == nil { // watch from latest good revision - rev = response.Header.Revision // TODO +1 ? + rev = response.Header.Revision // TODO: +1 ? useRev = true if !locked { retry = false @@ -1400,7 +1400,7 @@ func (obj *EmbdEtcd) nominateCallback(re *RE) error { if global.DEBUG { log.Printf("Etcd: nominateCallback(): newCluster: %v; exists: %v; obj.server == nil: %t", newCluster, exists, obj.server == nil) } - // XXX check if i have actually volunteered first of all... + // XXX: check if i have actually volunteered first of all... if obj.server == nil && (newCluster || exists) { log.Printf("Etcd: StartServer(newCluster: %t): %+v", newCluster, obj.nominated) @@ -1431,7 +1431,7 @@ func (obj *EmbdEtcd) nominateCallback(re *RE) error { // XXX: just put this wherever for now so we don't block // nominate self so "member" list is correct for peers to see EtcdNominate(obj, obj.hostname, obj.serverURLs) - // XXX if this fails, where will we retry this part ? + // XXX: if this fails, where will we retry this part ? } // advertise client urls @@ -1439,7 +1439,7 @@ func (obj *EmbdEtcd) nominateCallback(re *RE) error { // XXX: don't advertise local addresses! 127.0.0.1:2381 doesn't really help remote hosts // XXX: but sometimes this is what we want... hmmm how do we decide? filter on callback? EtcdAdvertiseEndpoints(obj, curls) - // XXX if this fails, where will we retry this part ? + // XXX: if this fails, where will we retry this part ? // force this to remove sentinel before we reconnect... obj.endpointCallback(nil) @@ -1655,7 +1655,7 @@ func (obj *EmbdEtcd) StartServer(newCluster bool, peerURLsMap etcdtypes.URLsMap) } else { cfg.ClusterState = embed.ClusterStateFlagExisting } - //cfg.ForceNewCluster = newCluster // TODO ? + //cfg.ForceNewCluster = newCluster // TODO: ? log.Printf("Etcd: StartServer: Starting server...") obj.server, err = embed.StartEtcd(cfg) @@ -1959,7 +1959,7 @@ func EtcdGetClusterSize(obj *EmbdEtcd) (uint16, error) { // EtcdMemberAdd adds a member to the cluster. func EtcdMemberAdd(obj *EmbdEtcd, peerURLs etcdtypes.URLs) (*etcd.MemberAddResponse, error) { - //obj.Connect(false) // TODO ? + //obj.Connect(false) // TODO: ? ctx := context.Background() var response *etcd.MemberAddResponse var err error @@ -1984,7 +1984,7 @@ func EtcdMemberAdd(obj *EmbdEtcd, peerURLs etcdtypes.URLs) (*etcd.MemberAddRespo // if there was an error. This is because it might have run without error, but // the member wasn't found, for example. func EtcdMemberRemove(obj *EmbdEtcd, mID uint64) (bool, error) { - //obj.Connect(false) // TODO ? + //obj.Connect(false) // TODO: ? ctx := context.Background() for { if obj.exiting { // the exit signal has been sent! @@ -2010,7 +2010,7 @@ func EtcdMemberRemove(obj *EmbdEtcd, mID uint64) (bool, error) { // The member ID's are the keys, because an empty names means unstarted! // TODO: consider queueing this through the main loop with CtxError(ctx, err) func EtcdMembers(obj *EmbdEtcd) (map[uint64]string, error) { - //obj.Connect(false) // TODO ? + //obj.Connect(false) // TODO: ? ctx := context.Background() var response *etcd.MemberListResponse var err error @@ -2041,7 +2041,7 @@ func EtcdMembers(obj *EmbdEtcd) (map[uint64]string, error) { // EtcdLeader returns the current leader of the etcd server cluster func EtcdLeader(obj *EmbdEtcd) (string, error) { - //obj.Connect(false) // TODO ? + //obj.Connect(false) // TODO: ? var err error membersMap := make(map[uint64]string) if membersMap, err = EtcdMembers(obj); err != nil { diff --git a/pgraph/pgraph.go b/pgraph/pgraph.go index 3c0aa131..aaca6905 100644 --- a/pgraph/pgraph.go +++ b/pgraph/pgraph.go @@ -792,7 +792,7 @@ func (g *Graph) Worker(v *Vertex) error { // TODO: resources could have a separate exit channel to avoid this complexity!? case event := <-obj.Events(): // NOTE: this code should match the similar Res code! - //cuuid.SetConverged(false) // TODO ? + //cuuid.SetConverged(false) // TODO: ? if exit, send := obj.ReadEvent(&event); exit { return nil // exit } else if send { diff --git a/recwatch/recwatch.go b/recwatch/recwatch.go index 75b93beb..730e881f 100644 --- a/recwatch/recwatch.go +++ b/recwatch/recwatch.go @@ -96,11 +96,11 @@ func (obj *RecWatcher) Init() error { return nil } -//func (obj *RecWatcher) Add(path string) error { // XXX implement me or not? +//func (obj *RecWatcher) Add(path string) error { // XXX: implement me or not? // //} // -//func (obj *RecWatcher) Remove(path string) error { // XXX implement me or not? +//func (obj *RecWatcher) Remove(path string) error { // XXX: implement me or not? // //} @@ -209,7 +209,7 @@ func (obj *RecWatcher) Watch() error { } } else { - // TODO different watchers get each others events! + // TODO: different watchers get each others events! // https://github.com/go-fsnotify/fsnotify/issues/95 // this happened with two values such as: // event.Name: /tmp/mgmt/f3 and current: /tmp/mgmt/f2 diff --git a/resources/exec.go b/resources/exec.go index 8f9bff59..9f3fffed 100644 --- a/resources/exec.go +++ b/resources/exec.go @@ -99,7 +99,7 @@ func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan ch <- scanner.Text() // blocks here ? if e := scanner.Err(); e != nil { errch <- e // send any misc errors we encounter - //break // TODO ? + //break // TODO: ? } } close(ch) @@ -236,8 +236,8 @@ func (obj *ExecRes) CheckApply(apply bool) (checkok bool, err error) { //} else if obj.IfCmd != "" && obj.WatchCmd != "" { if obj.PollInt > 0 { // && obj.WatchCmd == "" - // XXX have the Watch() command output onlyif poll events... - // XXX we can optimize by saving those results for returning here + // XXX: have the Watch() command output onlyif poll events... + // XXX: we can optimize by saving those results for returning here // return XXX } diff --git a/resources/file.go b/resources/file.go index 765ed2ce..48c7e54b 100644 --- a/resources/file.go +++ b/resources/file.go @@ -365,7 +365,7 @@ func (obj *FileRes) fileCheckApply(apply bool, src io.ReadSeeker, dst string, sh // hash comparison (efficient because we can cache hash of content str) if sha256sum == "" { // cache is invalid hash := sha256.New() - // TODO file existence test? + // TODO: file existence test? if _, err := io.Copy(hash, src); err != nil { return "", false, err } diff --git a/resources/msg.go b/resources/msg.go index caf4130e..f7819245 100644 --- a/resources/msg.go +++ b/resources/msg.go @@ -218,7 +218,7 @@ func (obj *MsgRes) isAllStateOK() bool { } // JournalPriority converts a string description to a numeric priority. -// XXX Have Validate() make sure it actually is one of these. +// XXX: Have Validate() make sure it actually is one of these. func (obj *MsgRes) journalPriority() journal.Priority { switch obj.Priority { case "Emerg": diff --git a/resources/resources.go b/resources/resources.go index 93d27ff6..582774ed 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -70,8 +70,8 @@ type AutoEdge interface { // MetaParams is a struct will all params that apply to every resource. type MetaParams struct { - AutoEdge bool `yaml:"autoedge"` // metaparam, should we generate auto edges? // XXX should default to true - AutoGroup bool `yaml:"autogroup"` // metaparam, should we auto group? // XXX should default to true + AutoEdge bool `yaml:"autoedge"` // metaparam, should we generate auto edges? // XXX: should default to true + AutoGroup bool `yaml:"autogroup"` // metaparam, should we auto group? // XXX: should default to true Noop bool `yaml:"noop"` // NOTE: there are separate Watch and CheckApply retry and delay values, // but I've decided to use the same ones for both until there's a proper @@ -253,7 +253,7 @@ func (obj *BaseRes) DoSend(processChan chan event.Event, comment string) (bool, // } //case event := <-obj.events: // // NOTE: this code should match the similar code below! - // //cuuid.SetConverged(false) // TODO ? + // //cuuid.SetConverged(false) // TODO: ? // if exit, send := obj.ReadEvent(&event); exit { // return true, nil // exit, without error // } else if send { diff --git a/resources/svc.go b/resources/svc.go index 8c36d538..6a7a8f38 100644 --- a/resources/svc.go +++ b/resources/svc.go @@ -145,7 +145,7 @@ func (obj *SvcRes) Watch(processChan chan event.Event) error { var notFound = (loadstate.Value == dbus.MakeVariant("not-found")) if notFound { // XXX: in the loop we'll handle changes better... log.Printf("Failed to find svc: %v", svc) - invalid = true // XXX ? + invalid = true // XXX: ? } } @@ -163,7 +163,7 @@ func (obj *SvcRes) Watch(processChan chan event.Event) error { obj.SetState(ResStateWatching) // reset select { - case <-buschan: // XXX wait for new units event to unstick + case <-buschan: // XXX: wait for new units event to unstick cuuid.SetConverged(false) // loop so that we can see the changed invalid signal log.Printf("Svc[%v]->DaemonReload()", svc) @@ -299,7 +299,7 @@ func (obj *SvcRes) CheckApply(apply bool) (checkok bool, err error) { var running = (activestate.Value == dbus.MakeVariant("active")) var stateOK = ((obj.State == "") || (obj.State == "running" && running) || (obj.State == "stopped" && !running)) - var startupOK = true // XXX DETECT AND SET + var startupOK = true // XXX: DETECT AND SET if stateOK && startupOK { return true, nil // we are in the correct state diff --git a/test/test-govet.sh b/test/test-govet.sh index 4fe0ff7e..4595648f 100755 --- a/test/test-govet.sh +++ b/test/test-govet.sh @@ -8,4 +8,5 @@ for file in `find . -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not - go vet "$file" && echo PASS || exit 1 # since it doesn't output an ok message on pass grep 'log.' "$file" | grep '\\n"' && echo 'no \n needed in log.Printf()' && exit 1 || echo PASS # no \n needed in log.Printf() grep 'case _ = <-' "$file" && echo 'case _ = <- can be simplified to: case <-' && exit 1 || echo PASS # this can be simplified + grep -Ei "[\/]+[\/]+[ ]*+(FIXME[^:]|TODO[^:]|XXX[^:])" "$file" && echo 'Token is missing a colon' && exit 1 || echo PASS # tokens must end with a colon done