Skip to content

Commit

Permalink
edits to trim number of IDE warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
e-gun committed Oct 24, 2022
1 parent a9dc749 commit 7cae473
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 32 deletions.
4 changes: 2 additions & 2 deletions buildsearchlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dbworklines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion initializeglobals.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ 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)
chke(e)
thehit.Entry = clean.Replace(thehit.Entry)
unnested[thehit.Entry] = thehit
}
foundrows.Close()
}

return unnested
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
14 changes: 7 additions & 7 deletions rt-browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<br>`
Expand Down Expand Up @@ -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, ", ")
Expand Down Expand Up @@ -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
Expand All @@ -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 "<observed id="abc">abc</observed> <observed id="def">def</observed>"
// the complication is that x.MarkedUp contains html; use x.Accented to find the words

Expand All @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion rt-hinters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions rt-lexica.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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] })
Expand Down Expand Up @@ -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)
Expand All @@ -569,6 +568,7 @@ func morphpossibintolexpossib(d string, mpp []MorphPossib) []DbLexicon {
lexicalfinds = append(lexicalfinds, thehit)
}
}
foundrows.Close()
}
return lexicalfinds
}
Expand Down
14 changes: 2 additions & 12 deletions rt-morphtables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rt-search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "$"
Expand Down
6 changes: 3 additions & 3 deletions rt-textsindicesandvocab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down Expand Up @@ -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
Expand All @@ -779,6 +778,7 @@ func arraytogetrequiredmorphobjects(wordlist []string) map[string]DbMorphology {
chke(err)
foundmorph[thehit.Observed] = thehit
}
foundrows.Close()
}
return foundmorph
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 7cae473

Please sign in to comment.