Skip to content

Commit

Permalink
Fix some golint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
iddan authored and dennwc committed Nov 14, 2019
1 parent 9d2ac5c commit 545fd2d
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion graph/gaedatastore/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (d *duration) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%q", *d)), nil
}

// Load reads a JSON-encoded config contained in the given file. A zero value
// LoadConf reads a JSON-encoded config contained in the given file. A zero value
// config is returned if the filename is empty.
func LoadConf(file string) (*Config, error) {
config := &Config{}
Expand Down
8 changes: 4 additions & 4 deletions graph/hasa.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type HasA struct {
dir quad.Direction
}

// Construct a new HasA iterator, given the quad subiterator, and the quad
// NewHasA construct a new HasA iterator, given the quad subiterator, and the quad
// direction for which it stands.
func NewHasA(qs QuadIndexer, subIt iterator.Shape, d quad.Direction) *HasA {
return &HasA{
Expand All @@ -70,15 +70,15 @@ func (it *HasA) Lookup() iterator.Index {
return newHasAContains(it.qs, it.primary.Lookup(), it.dir)
}

// Return our sole subiterator.
// SubIterators returns our sole subiterator.
func (it *HasA) SubIterators() []iterator.Shape {
return []iterator.Shape{it.primary}
}

// Direction accessor.
func (it *HasA) Direction() quad.Direction { return it.dir }

// Pass the Optimize() call along to the subiterator. If it becomes Null,
// Optimize pass the Optimize() call along to the subiterator. If it becomes Null,
// then the HasA becomes Null (there are no quads that have any directions).
func (it *HasA) Optimize(ctx context.Context) (iterator.Shape, bool) {
newPrimary, changed := it.primary.Optimize(ctx)
Expand All @@ -95,7 +95,7 @@ func (it *HasA) String() string {
return fmt.Sprintf("HasA(%v)", it.dir)
}

// GetStats() returns the statistics on the HasA iterator. This is curious. Next
// Stats returns the statistics on the HasA iterator. This is curious. Next
// cost is easy, it's an extra call or so on top of the subiterator Next cost.
// ContainsCost involves going to the graph.QuadStore, iterating out values, and hoping
// one sticks -- potentially expensive, depending on fanout. Size, however, is
Expand Down
2 changes: 1 addition & 1 deletion graph/iterator/and_optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func getStatsForSlice(ctx context.Context, its, opt []Shape) (Costs, []Costs, er
}, arr, last
}

// and.Stats() lives here in and-iterator-optimize.go because it may
// Stats lives here in and-iterator-optimize.go because it may
// in the future return different statistics based on how it is optimized.
// For now, however, it's pretty static.
//
Expand Down
8 changes: 4 additions & 4 deletions graph/linksto.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type LinksTo struct {
size refs.Size
}

// Construct a new LinksTo iterator around a direction and a subiterator of
// NewLinksTo construct a new LinksTo iterator around a direction and a subiterator of
// nodes.
func NewLinksTo(qs QuadIndexer, it iterator.Shape, d quad.Direction) *LinksTo {
return &LinksTo{
Expand All @@ -58,7 +58,7 @@ func NewLinksTo(qs QuadIndexer, it iterator.Shape, d quad.Direction) *LinksTo {
}
}

// Return the direction under consideration.
// Direction returns the direction under consideration.
func (it *LinksTo) Direction() quad.Direction { return it.dir }

func (it *LinksTo) Iterate() iterator.Scanner {
Expand All @@ -73,7 +73,7 @@ func (it *LinksTo) String() string {
return fmt.Sprintf("LinksTo(%v)", it.dir)
}

// Return a list containing only our subiterator.
// SubIterators returns a list containing only our subiterator.
func (it *LinksTo) SubIterators() []iterator.Shape {
return []iterator.Shape{it.primary}
}
Expand All @@ -90,7 +90,7 @@ func (it *LinksTo) Optimize(ctx context.Context) (iterator.Shape, bool) {
return it, false
}

// Return a guess as to how big or costly it is to next the iterator.
// Stats returns a guess as to how big or costly it is to next the iterator.
func (it *LinksTo) Stats(ctx context.Context) (iterator.Costs, error) {
subitStats, err := it.primary.Stats(ctx)
// TODO(barakmich): These should really come from the quadstore itself
Expand Down
2 changes: 1 addition & 1 deletion graph/quadwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (w *removeWriter) Flush() error {
}
func (w *removeWriter) Close() error { return nil }

// NewResultReader creates a quad reader for a given QuadStore.
// NewQuadStoreReader creates a quad reader for a given QuadStore.
func NewQuadStoreReader(qs QuadStore) quad.ReadSkipCloser {
return NewResultReader(qs, nil)
}
Expand Down
14 changes: 7 additions & 7 deletions graph/sql/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cayleygraph/cayley/clog"
"github.com/cayleygraph/cayley/graph"
"github.com/cayleygraph/cayley/graph/iterator"
"github.com/cayleygraph/cayley/graph/log"
graphlog "github.com/cayleygraph/cayley/graph/log"
"github.com/cayleygraph/cayley/graph/refs"
"github.com/cayleygraph/cayley/internal/lru"
"github.com/cayleygraph/quad"
Expand Down Expand Up @@ -208,18 +208,18 @@ func Init(typ string, addr string, options graph.Options) error {
}
defer conn.Close()

nodesSql := fl.nodesTable()
quadsSql := fl.quadsTable()
nodesSQL := fl.nodesTable()
quadsSQL := fl.quadsTable()
indexes := fl.quadIndexes(options)

if fl.NoSchemaChangesInTx {
_, err = conn.Exec(nodesSql)
_, err = conn.Exec(nodesSQL)
if err != nil {
err = fl.Error(err)
clog.Errorf("Cannot create nodes table: %v", err)
return err
}
_, err = conn.Exec(quadsSql)
_, err = conn.Exec(quadsSQL)
if err != nil {
err = fl.Error(err)
clog.Errorf("Cannot create quad table: %v", err)
Expand All @@ -238,14 +238,14 @@ func Init(typ string, addr string, options graph.Options) error {
return err
}

_, err = tx.Exec(nodesSql)
_, err = tx.Exec(nodesSQL)
if err != nil {
tx.Rollback()
err = fl.Error(err)
clog.Errorf("Cannot create nodes table: %v", err)
return err
}
_, err = tx.Exec(quadsSql)
_, err = tx.Exec(quadsSQL)
if err != nil {
tx.Rollback()
err = fl.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions internal/http/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func defaultErrorFunc(w query.ResponseWriter, err error) {
}

// TODO(barakmich): Turn this into proper middleware.

// ServeV1Query is the HTTP handler for queries in API V1
func (api *API) ServeV1Query(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
ctx, cancel := api.contextForRequest(r)
defer cancel()
Expand Down
2 changes: 1 addition & 1 deletion internal/lru/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

// TODO(kortschak) Reimplement without container/list.

// cache implements an LRU cache.
// Cache implements an LRU cache.
type Cache struct {
mu sync.Mutex
cache map[string]*list.Element
Expand Down
4 changes: 2 additions & 2 deletions query/graphql/graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ var casesExecute = []struct {
},
}

func toJson(o interface{}) string {
func toJSON(o interface{}) string {
buf := bytes.NewBuffer(nil)
json.NewEncoder(buf).Encode(o)
buf2 := bytes.NewBuffer(nil)
Expand All @@ -320,7 +320,7 @@ func TestExecute(t *testing.T) {
require.NoError(t, err)
out, err := q.Execute(context.Background(), qs)
require.NoError(t, err)
require.Equal(t, c.result, out, "results:\n%v\n\nvs\n\n%v", toJson(c.result), toJson(out))
require.Equal(t, c.result, out, "results:\n%v\n\nvs\n\n%v", toJSON(c.result), toJSON(out))
})
}
}
6 changes: 3 additions & 3 deletions query/path/pathtest/pathtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ func testSet(qs graph.QuadStore) []test {
{
message: "composite paths (clone paths)",
path: func() *Path {
alice_path := StartPath(qs, vAlice)
_ = alice_path.Out(vFollows)
alicePath := StartPath(qs, vAlice)
_ = alicePath.Out(vFollows)

return alice_path
return alicePath
}(),
expect: []quad.Value{vAlice},
},
Expand Down
4 changes: 2 additions & 2 deletions server/http/api_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (api *APIv2) ServeRead(w http.ResponseWriter, r *http.Request) {

func (api *APIv2) ServeFormats(w http.ResponseWriter, r *http.Request) {
type Format struct {
Id string `json:"id"`
ID string `json:"id"`
Read bool `json:"read,omitempty"`
Write bool `json:"write,omitempty"`
Nodes bool `json:"nodes,omitempty"`
Expand All @@ -406,7 +406,7 @@ func (api *APIv2) ServeFormats(w http.ResponseWriter, r *http.Request) {
out := make([]Format, 0, len(formats))
for _, f := range formats {
out = append(out, Format{
Id: f.Name,
ID: f.Name,
Ext: f.Ext, Mime: f.Mime,
Read: f.Reader != nil, Write: f.Writer != nil,
Nodes: f.UnmarshalValue != nil,
Expand Down

0 comments on commit 545fd2d

Please sign in to comment.