From 0bcd38193fdf8bf7a6776a11d59057def56538fc Mon Sep 17 00:00:00 2001 From: Xavier Llora Date: Tue, 18 Jul 2017 20:55:17 -0700 Subject: [PATCH] Bump to 8.1 dev and govet clean up --- bql/grammar/grammar_test.go | 38 +++++++++++++++++----------------- bql/planner/planner.go | 3 +-- bql/planner/planner_test.go | 18 ++++++++-------- bql/semantic/semantic.go | 4 ++-- bql/version/version.go | 4 ++-- docs/command_line_tool.md | 2 +- storage/storage.go | 6 +++--- tools/vcli/bw/repl/repl.go | 2 +- tools/vcli/bw/server/server.go | 2 +- triple/node/node.go | 2 +- 10 files changed, 40 insertions(+), 41 deletions(-) diff --git a/bql/grammar/grammar_test.go b/bql/grammar/grammar_test.go index e3688dba..e6b9509a 100644 --- a/bql/grammar/grammar_test.go +++ b/bql/grammar/grammar_test.go @@ -338,16 +338,16 @@ func TestAcceptGraphOpsByParseAndSemantic(t *testing.T) { t.Errorf("Parser.consume: Failed to accept entry %q with error %v", entry, err) } if got, want := st.GraphNames(), entry.graphs; !reflect.DeepEqual(got, want) { - t.Errorf("Parser.consume: Failed to collect the right graphs for case %v; got %d, want %d", entry, got, want) + t.Errorf("Parser.consume: Failed to collect the right graphs for case %v; got %v, want %v", entry, got, want) } if got, want := st.InputGraphNames(), entry.inputGraphs; !reflect.DeepEqual(got, want) { - t.Errorf("Parser.consume: Failed to collect the right input graphs for case %v; got %d, want %d", entry, got, want) + t.Errorf("Parser.consume: Failed to collect the right input graphs for case %v; got %v, want %v", entry, got, want) } if got, want := st.OutputGraphNames(), entry.outputGraphs; !reflect.DeepEqual(got, want) { - t.Errorf("Parser.consume: Failed to collect the right output graphs for case %v; got %d, want %d", entry, got, want) + t.Errorf("Parser.consume: Failed to collect the right output graphs for case %v; got %v, want %v", entry, got, want) } if got, want := len(st.Data()), entry.triples; got != want { - t.Errorf("Parser.consume: Failed to collect right number of triples for case %v; got %d, want %d", entry, got, want) + t.Errorf("Parser.consume: Failed to collect right number of triples for case %v; got %v, want %v", entry, got, want) } } } @@ -505,9 +505,9 @@ func TestSemanticStatementConstructClausesLengthCorrectness(t *testing.T) { func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) { table := []struct { - query string - want_one int - want_two int + query string + wantOne int + wantTwo int }{ { query: `construct {?s "predicate_1"@[] ?o1; @@ -518,8 +518,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) { where {?s "old_predicate_1"@[,] ?o1. ?s "old_predicate_2"@[,] ?o2. ?s "old_predicate_3"@[,] ?o3};`, - want_one: 2, - want_two: 1, + wantOne: 2, + wantTwo: 1, }, { query: `construct {?s "predicate_1"@[] ?o1; @@ -533,8 +533,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) { where {?s "old_predicate_1"@[,] ?o1. ?s "old_predicate_2"@[,] ?o2. ?s1 "old_predicate_3"@[,] ?o3};`, - want_one: 3, - want_two: 3, + wantOne: 3, + wantTwo: 3, }, { query: `construct {?s "predicate_1"@[2015-07-19T13:12:04.669618843-07:00] ?o1; @@ -545,8 +545,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) { where {?s "old_predicate_1"@[,] ?o1. ?s "old_predicate_2"@[,] ?o2. ?s "old_predicate_3"@[,] ?o3};`, - want_one: 2, - want_two: 1, + wantOne: 2, + wantTwo: 1, }, { query: `construct {?s "predicate_1"@[2015-07-19T13:12:04.669618843-07:00] ?o1; @@ -560,8 +560,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) { where {?s "old_predicate_1"@[,] ?o1. ?s "old_predicate_2"@[,] ?o2. ?s1 "old_predicate_3"@[,] ?o3};`, - want_one: 3, - want_two: 3, + wantOne: 3, + wantTwo: 3, }, { query: `construct {?s "predicate_1"@[] ?o1; @@ -575,8 +575,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) { where {?s "old_predicate_1"@[,] ?o1. ?s "old_predicate_2"@[,] ?o2. ?s1 "old_predicate_3"@[,] AT ?t ?o3};`, - want_one: 3, - want_two: 3, + wantOne: 3, + wantTwo: 3, }, } p, err := NewParser(SemanticBQL()) @@ -588,10 +588,10 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) { if err := p.Parse(NewLLk(entry.query, 1), st); err != nil { t.Errorf("Parser.consume: Failed to accept valid semantic entry %q", entry.query) } - if got, want := len(st.ConstructClauses()[0].PredicateObjectPairs()), entry.want_one; got != want { + if got, want := len(st.ConstructClauses()[0].PredicateObjectPairs()), entry.wantOne; got != want { t.Errorf("Invalid number of predicate-object pairs for query %q; got %d, want %d; %v", entry.query, got, want, st.ConstructClauses()[0].PredicateObjectPairs()) } - if got, want := len(st.ConstructClauses()[1].PredicateObjectPairs()), entry.want_two; got != want { + if got, want := len(st.ConstructClauses()[1].PredicateObjectPairs()), entry.wantTwo; got != want { t.Errorf("Invalid number of predicate-object pairs for query %q; got %d, want %d; %v", entry.query, got, want, st.ConstructClauses()[0].PredicateObjectPairs()) } } diff --git a/bql/planner/planner.go b/bql/planner/planner.go index bccc0c52..4d5f80c9 100644 --- a/bql/planner/planner.go +++ b/bql/planner/planner.go @@ -953,8 +953,7 @@ func (p *constructPlan) Execute(ctx context.Context) (*table.Table, error) { // We need to reify a blank node. rts, bn, err := t.Reify() if err != nil { - fmt.Errorf("triple.Reify failed to reify %v with error %v", t, err) - return nil, err + return nil, fmt.Errorf("triple.Reify failed to reify %v with error %v", t, err) } for _, trpl := range rts[1:] { tripChan <- trpl diff --git a/bql/planner/planner_test.go b/bql/planner/planner_test.go index 7795dfb7..c71f970e 100644 --- a/bql/planner/planner_test.go +++ b/bql/planner/planner_test.go @@ -228,7 +228,7 @@ func TestPlannerDropGraph(t *testing.T) { } } -func populateStoreWithTriples(s storage.Store, ctx context.Context, gn string, triples string, tb testing.TB) { +func populateStoreWithTriples(ctx context.Context, s storage.Store, gn string, triples string, tb testing.TB) { g, err := s.NewGraph(ctx, gn) if err != nil { tb.Fatalf("memory.NewGraph failed to create \"%v\" with error %v", gn, err) @@ -452,7 +452,7 @@ func TestPlannerQuery(t *testing.T) { } s, ctx := memory.NewStore(), context.Background() - populateStoreWithTriples(s, ctx, "?test", testTriples, t) + populateStoreWithTriples(ctx, s, "?test", testTriples, t) p, err := grammar.NewParser(grammar.SemanticBQL()) if err != nil { t.Fatalf("grammar.NewParser: should have produced a valid BQL parser with error %v", err) @@ -550,8 +550,8 @@ func TestPlannerConstructAddsCorrectNumberofTriples(t *testing.T) { for _, entry := range testTable { s, ctx := memory.NewStore(), context.Background() - populateStoreWithTriples(s, ctx, "?src", constructTestSrcTriples, t) - populateStoreWithTriples(s, ctx, "?dest", constructTestDestTriples, t) + populateStoreWithTriples(ctx, s, "?src", constructTestSrcTriples, t) + populateStoreWithTriples(ctx, s, "?dest", constructTestDestTriples, t) st := &semantic.Statement{} if err := p.Parse(grammar.NewLLk(entry.s, 1), st); err != nil { @@ -602,8 +602,8 @@ func TestPlannerConstructAddsCorrectTriples(t *testing.T) { t.Errorf("grammar.NewParser: should have produced a valid BQL parser, %v", err) } s, ctx := memory.NewStore(), context.Background() - populateStoreWithTriples(s, ctx, "?src", constructTestSrcTriples, t) - populateStoreWithTriples(s, ctx, "?dest", "", t) + populateStoreWithTriples(ctx, s, "?src", constructTestSrcTriples, t) + populateStoreWithTriples(ctx, s, "?dest", "", t) st := &semantic.Statement{} if err := p.Parse(grammar.NewLLk(bql, 1), st); err != nil { @@ -656,7 +656,7 @@ func TestPlannerConstructAddsCorrectTriples(t *testing.T) { for elem := range ts { sts = append(sts, elem) if elem.Subject().Type().String() == "/_" { - for k, _ := range dtm { + for k := range dtm { trp, err := triple.Parse(k, literal.DefaultBuilder()) if err != nil { t.Errorf("Unable to parse triple: %v with error %v", k, err) @@ -682,7 +682,7 @@ func TestPlannerConstructAddsCorrectTriples(t *testing.T) { // checking if the triple exists in the map of expected triples. for _, t := range sts { if t.Subject().Type().String() == "/_" { - for bn, _ := range bnm[t.Subject().String()] { + for bn := range bnm[t.Subject().String()] { rep := fmt.Sprintf("%s\t%s\t%s", bn, t.Predicate().String(), t.Object().String()) if _, ok := dtm[rep]; !ok { bnm[t.Subject().String()][bn] = false @@ -891,7 +891,7 @@ func benchmarkQuery(query string, b *testing.B) { ctx := context.Background() s, ctx := memory.NewStore(), context.Background() - populateStoreWithTriples(s, ctx, "?test", testTriples, b) + populateStoreWithTriples(ctx, s, "?test", testTriples, b) p, err := grammar.NewParser(grammar.SemanticBQL()) if err != nil { b.Fatalf("grammar.NewParser: should have produced a valid BQL parser with error %v", err) diff --git a/bql/semantic/semantic.go b/bql/semantic/semantic.go index 50fe4141..b42780f8 100644 --- a/bql/semantic/semantic.go +++ b/bql/semantic/semantic.go @@ -138,7 +138,7 @@ type ConstructClause struct { S *node.Node SBinding string - predicateObjectPairs []*ConstructPredicateObjectPair + predicateObjectPairs []*ConstructPredicateObjectPair workingPredicateObjectPair *ConstructPredicateObjectPair } @@ -387,7 +387,7 @@ func (c *ConstructClause) String() string { for _, pop := range c.PredicateObjectPairs() { b.WriteString(fmt.Sprintf("%v;", pop)) } - b.Truncate(b.Len()-1) + b.Truncate(b.Len() - 1) b.WriteString(" }") return b.String() } diff --git a/bql/version/version.go b/bql/version/version.go index 19df2f65..daf50c3a 100644 --- a/bql/version/version.go +++ b/bql/version/version.go @@ -20,9 +20,9 @@ var ( // Minor is the current minor version of master branch. Minor = 8 // Patch is the current patched version of the master branch. - Patch = 0 + Patch = 1 // Release is the current release level of the master branch. Valid values // are dev (development unreleased), rcX (release candidate with current // iteration), stable (indicates a final released version). - Release = "stable" + Release = "dev" ) diff --git a/docs/command_line_tool.md b/docs/command_line_tool.md index cdefdc99..8a545efb 100644 --- a/docs/command_line_tool.md +++ b/docs/command_line_tool.md @@ -378,7 +378,7 @@ $ badwolf export ?graph1,?graph2,?grpah3 ./triples.txt ## Command: Server Ther ```server``` command starts a simple HTTP endpoint for BQL commands on -the provided port. +the provided port. ``` $ bw server 1234 diff --git a/storage/storage.go b/storage/storage.go index dbb029a4..06616d08 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -126,7 +126,7 @@ type Graph interface { Objects(ctx context.Context, s *node.Node, p *predicate.Predicate, lo *LookupOptions, objs chan<- *triple.Object) error // Subject pushes to the provided channel the subjects for the give predicate - // and object. The function does not return immediately. The caller is + // and object. The function does not return immediately. The caller is // expected to detach them into a go routine. // // Given a predicate and an object, this method retrieves the subjects of @@ -180,7 +180,7 @@ type Graph interface { PredicatesForSubjectAndObject(ctx context.Context, s *node.Node, o *triple.Object, lo *LookupOptions, prds chan<- *predicate.Predicate) error // TriplesForSubject pushes to the provided channel all triples available for - // the given subject. The function does not return immediately. The caller + // the given subject. The function does not return immediately. The caller // is expected to detach them into a go routine. // // If the lookup options provide a max number of elements the function will @@ -191,7 +191,7 @@ type Graph interface { TriplesForSubject(ctx context.Context, s *node.Node, lo *LookupOptions, trpls chan<- *triple.Triple) error // TriplesForPredicate pushes to the provided channel all triples available - // for the given predicate.The function does not return immediatel. The + // for the given predicate.The function does not return immediatel. The // caller is expected to detach them into a go routine. // // If the lookup options provide a max number of elements the function will diff --git a/tools/vcli/bw/repl/repl.go b/tools/vcli/bw/repl/repl.go index 49fa6382..dfc1f357 100644 --- a/tools/vcli/bw/repl/repl.go +++ b/tools/vcli/bw/repl/repl.go @@ -106,7 +106,7 @@ func REPL(driver storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize fmt.Printf("Using driver %q. Type quit; to exit\n", driver.Name(ctx)) fmt.Printf("Session started at %v\n\n", sessionStart) defer func() { - fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Now().Sub(sessionStart) ) + fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Now().Sub(sessionStart)) }() for l := range rl(done) { diff --git a/tools/vcli/bw/server/server.go b/tools/vcli/bw/server/server.go index a4e537b0..290e4299 100644 --- a/tools/vcli/bw/server/server.go +++ b/tools/vcli/bw/server/server.go @@ -98,7 +98,7 @@ func (s *serverConfig) bqlHandler(w http.ResponseWriter, r *http.Request) { return } if r.Method != http.MethodPost { - reportError(w, r, fmt.Errorf("invalid %s request on %q endpoint. Only POST request are accepted.", r.Method, r.URL.Path)) + reportError(w, r, fmt.Errorf("invalid %s request on %q endpoint. Only POST request are accepted", r.Method, r.URL.Path)) log.Printf("[%s] Invalid request: %#v\n", time.Now(), r) return } diff --git a/triple/node/node.go b/triple/node/node.go index e8fcd0b5..c903bc67 100644 --- a/triple/node/node.go +++ b/triple/node/node.go @@ -105,7 +105,7 @@ func Parse(s string) (*Node, error) { if err != nil { return nil, fmt.Errorf("node.Parse: invalid ID in %q, %v", raw, err) } - t, _ := NewType("/_") + t, _ := NewType("/_") return NewNode(t, id), nil default: return nil, fmt.Errorf("node.Parse: node representation should start with '/' or '_' in %v", raw)