0
0

additional golint issues resolved

This commit is contained in:
Marty Schoch 2014-09-03 18:17:26 -04:00
parent d534b0836b
commit 377ae090d0
7 changed files with 35 additions and 35 deletions

View File

@ -36,7 +36,7 @@ func (p *FlexibleGoDateTimeParser) ParseDateTime(input string) (time.Time, error
return rv, nil
}
}
return time.Time{}, analysis.InvalidDateTime
return time.Time{}, analysis.ErrInvalidDateTime
}
func FlexibleGoDateTimeParserConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.DateTimeParser, error) {

View File

@ -53,7 +53,7 @@ func TestFlexibleDateTimeParser(t *testing.T) {
{
input: "not a date time",
expectedTime: time.Time{},
expectedError: analysis.InvalidDateTime,
expectedError: analysis.ErrInvalidDateTime,
},
}

View File

@ -49,7 +49,7 @@ func (tfs TokenFrequencies) MergeAll(remoteField string, other TokenFrequencies)
i := 0
for _, tf := range index {
rv[i] = tf
i += 1
i++
}
return rv
}
@ -83,7 +83,7 @@ func TokenFrequency(tokens TokenStream) TokenFrequencies {
i := 0
for _, tf := range index {
rv[i] = tf
i += 1
i++
}
return rv

View File

@ -23,12 +23,12 @@ func NewTokenMap() TokenMap {
return make(TokenMap, 0)
}
func (s TokenMap) LoadFile(filename string) error {
func (t TokenMap) LoadFile(filename string) error {
data, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
return s.LoadBytes(data)
return t.LoadBytes(data)
}
func (t TokenMap) LoadBytes(data []byte) error {

View File

@ -70,7 +70,7 @@ func (a *Analyzer) Analyze(input []byte) TokenStream {
return tokens
}
var InvalidDateTime = fmt.Errorf("unable to parse datetime with any of the layouts")
var ErrInvalidDateTime = fmt.Errorf("unable to parse datetime with any of the layouts")
type DateTimeParser interface {
ParseDateTime(string) (time.Time, error)

View File

@ -22,7 +22,7 @@ import (
"code.google.com/p/goprotobuf/proto"
)
var VersionKey []byte = []byte{'v'}
var VersionKey = []byte{'v'}
const Version uint8 = 1
@ -105,7 +105,7 @@ func (udc *UpsideDownCouch) batchRows(addRows []UpsideDownCouchRow, updateRows [
if err != nil {
return err
}
tr.freq += 1 // incr
tr.freq++ // incr
} else {
tr = NewTermFrequencyRow(tfr.term, tfr.field, "", 1, 0)
}
@ -136,7 +136,7 @@ func (udc *UpsideDownCouch) batchRows(addRows []UpsideDownCouchRow, updateRows [
if err != nil {
return err
}
tr.freq -= 1 // incr
tr.freq-- // incr
} else {
return fmt.Errorf("unexpected missing row, deleting term, expected count row to exist: %v", tr.Key())
}
@ -193,13 +193,13 @@ func (udc *UpsideDownCouch) countDocs() uint64 {
it := udc.store.Iterator([]byte{'b'})
defer it.Close()
var rv uint64 = 0
var rv uint64
key, _, valid := it.Current()
for valid {
if !bytes.HasPrefix(key, []byte{'b'}) {
break
}
rv += 1
rv++
it.Next()
key, _, valid = it.Current()
}
@ -211,10 +211,10 @@ func (udc *UpsideDownCouch) rowCount() uint64 {
it := udc.store.Iterator([]byte{0})
defer it.Close()
var rv uint64 = 0
var rv uint64
_, _, valid := it.Current()
for valid {
rv += 1
rv++
it.Next()
_, _, valid = it.Current()
}
@ -243,7 +243,7 @@ func (udc *UpsideDownCouch) Update(doc *document.Document) error {
err = udc.batchRows(addRows, updateRows, deleteRows)
if err == nil && backIndexRow == nil {
udc.docCount += 1
udc.docCount++
}
return err
}
@ -317,7 +317,7 @@ func (udc *UpsideDownCouch) updateSingle(doc *document.Document, backIndexRow *B
updateRows = append(updateRows, backIndexRow)
// any of the existing rows that weren't updated need to be deleted
for existingTermKey, _ := range existingTermKeys {
for existingTermKey := range existingTermKeys {
termFreqRow, err := NewTermFrequencyRowK([]byte(existingTermKey))
if err == nil {
deleteRows = append(deleteRows, termFreqRow)
@ -325,7 +325,7 @@ func (udc *UpsideDownCouch) updateSingle(doc *document.Document, backIndexRow *B
}
// any of the existing stored fields that weren't updated need to be deleted
for existingStoredKey, _ := range existingStoredKeys {
for existingStoredKey := range existingStoredKeys {
storedRow, err := NewStoredRowK([]byte(existingStoredKey))
if err == nil {
deleteRows = append(deleteRows, storedRow)
@ -440,7 +440,7 @@ func (udc *UpsideDownCouch) Delete(id string) error {
err = udc.batchRows(nil, nil, deleteRows)
if err == nil {
udc.docCount -= 1
udc.docCount--
}
return err
}
@ -485,7 +485,7 @@ func (udc *UpsideDownCouch) backIndexRowsForBatch(batch index.Batch) (map[string
// FIXME faster to order the ids and scan sequentially
// for now just get it working
rv := make(map[string]*BackIndexRow, 0)
for docId, _ := range batch {
for docId := range batch {
backIndexRow, err := udc.backIndexRowForDoc(docId)
if err != nil {
return nil, err

View File

@ -37,7 +37,7 @@ func TestIndexOpenReopen(t *testing.T) {
t.Errorf("error opening index: %v", err)
}
var expectedCount uint64 = 0
var expectedCount uint64
docCount := idx.DocCount()
if docCount != expectedCount {
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
@ -78,7 +78,7 @@ func TestIndexInsert(t *testing.T) {
}
defer idx.Close()
var expectedCount uint64 = 0
var expectedCount uint64
docCount := idx.DocCount()
if docCount != expectedCount {
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
@ -90,7 +90,7 @@ func TestIndexInsert(t *testing.T) {
if err != nil {
t.Errorf("Error updating index: %v", err)
}
expectedCount += 1
expectedCount++
docCount = idx.DocCount()
if docCount != expectedCount {
@ -116,7 +116,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
}
defer idx.Close()
var expectedCount uint64 = 0
var expectedCount uint64
docCount := idx.DocCount()
if docCount != expectedCount {
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
@ -128,7 +128,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
if err != nil {
t.Errorf("Error updating index: %v", err)
}
expectedCount += 1
expectedCount++
doc2 := document.NewDocument("2")
doc2.AddField(document.NewTextField("name", []uint64{}, []byte("test")))
@ -136,7 +136,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
if err != nil {
t.Errorf("Error updating index: %v", err)
}
expectedCount += 1
expectedCount++
docCount = idx.DocCount()
if docCount != expectedCount {
@ -147,7 +147,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
if err != nil {
t.Errorf("Error deleting entry from index: %v", err)
}
expectedCount -= 1
expectedCount--
docCount = idx.DocCount()
if docCount != expectedCount {
@ -158,7 +158,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
if err != nil {
t.Errorf("Error deleting entry from index: %v", err)
}
expectedCount -= 1
expectedCount--
docCount = idx.DocCount()
if docCount != expectedCount {
@ -232,7 +232,7 @@ func TestIndexInsertMultiple(t *testing.T) {
t.Errorf("error opening index: %v", err)
}
var expectedCount uint64 = 0
var expectedCount uint64
doc := document.NewDocument("1")
doc.AddField(document.NewTextField("name", []uint64{}, []byte("test")))
@ -295,7 +295,7 @@ func TestIndexInsertWithStore(t *testing.T) {
}
defer idx.Close()
var expectedCount uint64 = 0
var expectedCount uint64
docCount := idx.DocCount()
if docCount != expectedCount {
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
@ -307,7 +307,7 @@ func TestIndexInsertWithStore(t *testing.T) {
if err != nil {
t.Errorf("Error updating index: %v", err)
}
expectedCount += 1
expectedCount++
docCount = idx.DocCount()
if docCount != expectedCount {
@ -400,7 +400,7 @@ func TestIndexBatch(t *testing.T) {
}
defer idx.Close()
var expectedCount uint64 = 0
var expectedCount uint64
// first create 2 docs the old fashioned way
doc := document.NewDocument("1")
@ -409,7 +409,7 @@ func TestIndexBatch(t *testing.T) {
if err != nil {
t.Errorf("Error updating index: %v", err)
}
expectedCount += 1
expectedCount++
doc = document.NewDocument("2")
doc.AddField(document.NewTextField("name", []uint64{}, []byte("test2")))
@ -417,7 +417,7 @@ func TestIndexBatch(t *testing.T) {
if err != nil {
t.Errorf("Error updating index: %v", err)
}
expectedCount += 1
expectedCount++
// now create a batch which does 3 things
// insert new doc
@ -477,7 +477,7 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) {
}
defer idx.Close()
var expectedCount uint64 = 0
var expectedCount uint64
docCount := idx.DocCount()
if docCount != expectedCount {
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
@ -495,7 +495,7 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) {
if err != nil {
t.Errorf("Error updating index: %v", err)
}
expectedCount += 1
expectedCount++
docCount = idx.DocCount()
if docCount != expectedCount {