From 7cae4738b84b91282a47ae51bd1c3dfbc12008e2 Mon Sep 17 00:00:00 2001 From: e-gun Date: Mon, 24 Oct 2022 09:38:22 -0400 Subject: [PATCH] edits to trim number of IDE warnings --- buildsearchlist.go | 4 ++-- dbworklines.go | 2 +- initializeglobals.go | 2 +- main.go | 2 +- rt-browser.go | 14 +++++++------- rt-hinters.go | 2 +- rt-lexica.go | 6 +++--- rt-morphtables.go | 14 ++------------ rt-search.go | 2 +- rt-textsindicesandvocab.go | 6 +++--- 10 files changed, 22 insertions(+), 32 deletions(-) diff --git a/buildsearchlist.go b/buildsearchlist.go index c7ed81f..dfc7926 100644 --- a/buildsearchlist.go +++ b/buildsearchlist.go @@ -31,7 +31,7 @@ type SearchIncExl struct { ListedWBN []string } -func (i SearchIncExl) isEmpty() bool { +func (i *SearchIncExl) isEmpty() bool { l := len(i.AuGenres) + len(i.WkGenres) + len(i.AuLocations) + len(i.WkLocations) + len(i.Authors) l += len(i.Works) + len(i.Passages) if l > 0 { @@ -41,7 +41,7 @@ func (i SearchIncExl) isEmpty() bool { } } -func (i SearchIncExl) CountItems() int { +func (i *SearchIncExl) CountItems() int { l := len(i.AuGenres) + len(i.WkGenres) + len(i.AuLocations) + len(i.WkLocations) + len(i.Authors) l += len(i.Works) + len(i.Passages) return l diff --git a/dbworklines.go b/dbworklines.go index 502d9b5..602f276 100644 --- a/dbworklines.go +++ b/dbworklines.go @@ -390,7 +390,7 @@ func findvalidlevelvalues(wkid string, locc []string) LevelValues { vals.Low = lines[0].LvlVal(atlvl) vals.High = lines[len(lines)-1].LvlVal(atlvl) var r []string - for i, _ := range lines { + for i := range lines { r = append(r, lines[i].LvlVal(atlvl)) } r = unique(r) diff --git a/initializeglobals.go b/initializeglobals.go index 1279925..ac4cf69 100644 --- a/initializeglobals.go +++ b/initializeglobals.go @@ -297,7 +297,6 @@ func lemmamapper() map[string]DbLemma { q := fmt.Sprintf(t, lg) foundrows, err := dbconn.Query(context.Background(), q) chke(err) - defer foundrows.Close() for foundrows.Next() { var thehit DbLemma e := foundrows.Scan(&thehit.Entry, &thehit.Xref, &thehit.Deriv) @@ -305,6 +304,7 @@ func lemmamapper() map[string]DbLemma { thehit.Entry = clean.Replace(thehit.Entry) unnested[thehit.Entry] = thehit } + foundrows.Close() } return unnested diff --git a/main.go b/main.go index 5a4239c..11fe272 100644 --- a/main.go +++ b/main.go @@ -254,7 +254,7 @@ func configatlaunch() { if erra != nil && errb != nil { msg(fmt.Sprintf(FAIL3, cf, acf), 0) msg(fmt.Sprintf(FAIL4), 0) - fmt.Println(MINCONFIG) + fmt.Printf(MINCONFIG) os.Exit(0) } conf := ConfigFile{} diff --git a/rt-browser.go b/rt-browser.go index 7e30691..0c7db6f 100644 --- a/rt-browser.go +++ b/rt-browser.go @@ -160,7 +160,7 @@ func generatebrowsedpassage(au string, wk string, fc int64, ctx int64) BrowsedPa // want to do what follows in some sort of regular order nk := []string{"#", "", "loc", "pub", "c:", "r:", "d:"} - for i, _ := range lines { + for i := range lines { lines[i].GatherMetadata() if len(lines[i].EmbNotes) != 0 { nt := `%s %s
` @@ -315,7 +315,7 @@ func basiccitation(l DbWorkline) string { cf = cf[6-(len(loc)) : 6] var cit []string - for i, _ := range loc { + for i := range loc { cit = append(cit, fmt.Sprintf("%s %s", cf[i], loc[i])) } fullcit := strings.Join(cit, ", ") @@ -363,7 +363,7 @@ func buildbrowsertable(focus int64, lines []DbWorkline) string { allwords := func() []string { wm := make(map[string]bool) - for i, _ := range lines { + for i := range lines { wds := strings.Split(lines[i].Accented, " ") for _, w := range wds { wm[w] = true @@ -388,7 +388,7 @@ func buildbrowsertable(focus int64, lines []DbWorkline) string { return ar }() - for i, _ := range lines { + for i := range lines { // turn "abc def" into "abc def" // the complication is that x.MarkedUp contains html; use x.Accented to find the words @@ -403,9 +403,9 @@ func buildbrowsertable(focus int64, lines []DbWorkline) string { mw := strings.Split(lines[i].MarkedUp, " ") lmw := mw[len(mw)-1] - for w, _ := range wds { - p := almostallregex[wds[w]] - if w == len(wds)-1 && terminalhyph.MatchString(lmw) { + for j := range wds { + p := almostallregex[wds[j]] + if j == len(wds)-1 && terminalhyph.MatchString(lmw) { // wds[lastwordindex] is the unhyphenated word // almostallregex does not contain this pattern: "ἱμα-", e.g. np, e := regexp.Compile(fmt.Sprintf(OBSREGTEMPL, capsvariants(lmw))) diff --git a/rt-hinters.go b/rt-hinters.go index 04ce75d..850a813 100644 --- a/rt-hinters.go +++ b/rt-hinters.go @@ -123,7 +123,7 @@ func basichinter(c echo.Context, mastermap map[string]bool) error { // is what we have a match? var ff []string - for f, _ := range mastermap { + for f := range mastermap { if strings.Contains(f, skg) { ff = append(ff, f) } diff --git a/rt-lexica.go b/rt-lexica.go index 7e9898c..9bac8da 100644 --- a/rt-lexica.go +++ b/rt-lexica.go @@ -348,7 +348,7 @@ func reversefind(word string, dicts []string) string { htmlmap := paralleldictformatter(lexicalfinds) var keys []float32 - for k, _ := range htmlmap { + for k := range htmlmap { keys = append(keys, k) } @@ -396,7 +396,7 @@ func dictsearch(seeking string, dict string) string { htmlmap := paralleldictformatter(lexicalfinds) var keys []float32 - for k, _ := range htmlmap { + for k := range htmlmap { keys = append(keys, k) } sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) @@ -557,7 +557,6 @@ func morphpossibintolexpossib(d string, mpp []MorphPossib) []DbLexicon { foundrows, err := dbconn.Query(context.Background(), q) chke(err) - defer foundrows.Close() for foundrows.Next() { var thehit DbLexicon e := foundrows.Scan(&thehit.Word, &thehit.Metrical, &thehit.ID, &thehit.POS, &thehit.Transl, &thehit.Entry) @@ -569,6 +568,7 @@ func morphpossibintolexpossib(d string, mpp []MorphPossib) []DbLexicon { lexicalfinds = append(lexicalfinds, thehit) } } + foundrows.Close() } return lexicalfinds } diff --git a/rt-morphtables.go b/rt-morphtables.go index 2903c70..f73c5a2 100644 --- a/rt-morphtables.go +++ b/rt-morphtables.go @@ -191,7 +191,7 @@ func RtMorphchart(c echo.Context) error { //(12 rows) wcc := make(map[string]DbWordCount) - for l, _ := range lett { + for l := range lett { if []rune(l)[0] == 0 { continue } @@ -204,13 +204,13 @@ func RtMorphchart(c echo.Context) error { rr, e := dbconn.Query(context.Background(), q) chke(e) var wc DbWordCount - defer rr.Close() for rr.Next() { ee := rr.Scan(&wc.Word, &wc.Total) chke(ee) // you just found »ἥρμοττ« which gives you »ἥρμοττ'«: see below for where this becomes an issue wcc[wc.Word] = wc } + rr.Close() } // [d] extract parsing info for all forms @@ -1023,16 +1023,6 @@ func multistringseeker(ss []string, split string) bool { return false } -// arraystringseeker - if any s in []string is in the []strings produced via splitting each of spp, then true -func arraystringseeker(ss []string, spp []string) bool { - for _, sp := range spp { - if multistringseeker(ss, sp) { - return true - } - } - return false -} - // arraystringcounter - if any s in []string is in the []strings produced via splitting each of spp, then add to the count func arraystringcounter(ss []string, spp []string) int { count := 0 diff --git a/rt-search.go b/rt-search.go index 46ef049..6b17306 100644 --- a/rt-search.go +++ b/rt-search.go @@ -622,7 +622,7 @@ func findphrasesacrosslines(ss *SearchStruct) { ww := strings.Split(phr, " ") var comb [][2]string - for i, _ := range ww { + for i := range ww { h := strings.Join(gh(i, ww), " ") t := strings.Join(gt(i, ww), " ") h = h + "$" diff --git a/rt-textsindicesandvocab.go b/rt-textsindicesandvocab.go index 11a6a58..698a9b0 100644 --- a/rt-textsindicesandvocab.go +++ b/rt-textsindicesandvocab.go @@ -617,7 +617,7 @@ func RtIndexMaker(c echo.Context) error { } plainmap := make(map[string][]WordInfo, len(indexmap)) - for k, _ := range indexmap { + for k := range indexmap { plainmap[k.value] = indexmap[k] } @@ -770,7 +770,6 @@ func arraytogetrequiredmorphobjects(wordlist []string) map[string]DbMorphology { foundrows, e := dbconn.Query(context.Background(), fmt.Sprintf(QT, uselang, id, uselang)) chke(e) - defer foundrows.Close() count := 0 for foundrows.Next() { count += 1 @@ -779,6 +778,7 @@ func arraytogetrequiredmorphobjects(wordlist []string) map[string]DbMorphology { chke(err) foundmorph[thehit.Observed] = thehit } + foundrows.Close() } return foundmorph } @@ -879,7 +879,7 @@ func convertwordinfototablerow(ww []WordInfo) string { // sort the keys keys := make([]string, len(indexmap)) count := 0 - for k, _ := range indexmap { + for k := range indexmap { keys[count] = k count += 1 }