From 6d9ae540e3648707cb2fe271e6a5632f391b8676 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 10 Nov 2019 16:18:27 -0800 Subject: [PATCH] Responds to GoMetaLinter for more of the codebase. --- client.go | 9 +++++---- main.go | 8 ++++---- page.go | 3 +++ pages.go | 14 ++++++++++++++ url.go | 5 +++++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/client.go b/client.go index 35fd5af..699871f 100644 --- a/client.go +++ b/client.go @@ -51,7 +51,7 @@ func (c *client) GetSizeOnce() { os.Exit(5) } var h, w int - fmt.Sscan(string(out), &h, &w) + _, _ = fmt.Sscan(string(out), &h, &w) c.Height = h c.Width = w } @@ -70,7 +70,7 @@ func (c *client) GetSize() { os.Exit(5) } var h, w int - fmt.Sscan(string(out), &h, &w) + _, _ = fmt.Sscan(string(out), &h, &w) if h != c.Height || w != c.Width { c.Height = h c.Width = w @@ -268,7 +268,7 @@ func (c *client) routeCommandInput(com *cmdparse.Command) error { case cmdparse.DOLINKAS: c.doLinkCommandAs(com.Action, com.Target, com.Value) default: - return fmt.Errorf("Unknown command entry!") + return fmt.Errorf("Unknown command entry") } return err @@ -1049,7 +1049,8 @@ func (c *client) handleWeb(u Url) { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ -// Creates a client instance and names the client after the string that is passed in +// MakeClient returns a client struct and names the client after +// the string that is passed in func MakeClient(name string) *client { c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()} return &c diff --git a/main.go b/main.go index 3c03392..4b644bb 100644 --- a/main.go +++ b/main.go @@ -106,7 +106,7 @@ func loadConfig() error { confparser := config.NewParser(file) settings, _ = confparser.Parse() - file.Close() + _ = file.Close() for _, v := range settings.Settings { lowerkey := strings.ToLower(v.Key) if lowerkey == "configlocation" { @@ -128,7 +128,7 @@ func loadConfig() error { } for i, v := range settings.Bookmarks.Titles { - bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]}) + _, _ = bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]}) } for _, v := range settings.Certs { @@ -156,7 +156,7 @@ func handleSignals(c <-chan os.Signal) { switch <-c { case syscall.SIGTSTP: cui.CleanupTerm() - syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) + _ = syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) case syscall.SIGCONT: cui.InitTerm() bombadillo.Draw() @@ -178,7 +178,7 @@ Examples: bombadillo gopher://bombadillo.colorfield.space Options: ` - fmt.Fprint(os.Stdout, art) + _, _ = fmt.Fprint(os.Stdout, art) flag.PrintDefaults() } diff --git a/page.go b/page.go index 891b86d..4e7b54c 100644 --- a/page.go +++ b/page.go @@ -23,6 +23,8 @@ type Page struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +// ScrollPositionRange may not be in actual usage.... +// TODO: find where this is being used func (p *Page) ScrollPositionRange(termHeight int) (int, int) { termHeight -= 3 if len(p.WrappedContent)-p.ScrollPosition < termHeight { @@ -88,6 +90,7 @@ func (p *Page) WrapContent(width int) { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// MakePage returns a Page struct with default values func MakePage(url Url, content string, links []string) Page { p := Page{make([]string, 0), content, links, url, 0} return p diff --git a/pages.go b/pages.go index 90f570a..3a1db87 100644 --- a/pages.go +++ b/pages.go @@ -8,6 +8,9 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Pages is a struct that represents the history of the client. +// It functions as a container for the pages (history array) and +// tracks the current history length and location. type Pages struct { Position int Length int @@ -18,6 +21,10 @@ type Pages struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +// NavigateHistory takes a positive or negative integer +// and updates the current history position. Checks are done +// to make sure that the position moved to is a valid history +// location. Returns an error or nil. func (p *Pages) NavigateHistory(qty int) error { newPosition := p.Position + qty if newPosition < 0 { @@ -30,6 +37,10 @@ func (p *Pages) NavigateHistory(qty int) error { return nil } +// Add gets passed a Page, which gets added to the history +// arrayr. Add also updates the current length and position +// of the Pages struct to which it belongs. Add also shifts +// off array items if necessary. func (p *Pages) Add(pg Page) { if p.Position == p.Length-1 && p.Length < len(p.History) { p.History[p.Length] = pg @@ -47,6 +58,8 @@ func (p *Pages) Add(pg Page) { } } +// Render wraps the content for the current page and returns +// the page content as a string slice func (p *Pages) Render(termHeight, termWidth int) []string { if p.Length < 1 { return make([]string, 0) @@ -79,6 +92,7 @@ func (p *Pages) Render(termHeight, termWidth int) []string { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// MakePages returns a Pages struct with default values func MakePages() Pages { return Pages{-1, 0, [20]Page{}} } diff --git a/url.go b/url.go index aaa2cbd..bc1895a 100644 --- a/url.go +++ b/url.go @@ -12,6 +12,11 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Url is a struct representing the different pieces +// of a url. This custom struct is used rather than the +// built-in url library so-as to support gopher URLs, as +// well as track mime-type and renderability (can the +// response to the url be rendered as text in the client). type Url struct { Scheme string Host string