From de41930d0a6a6925819b08a69d015612c6879dbc Mon Sep 17 00:00:00 2001 From: makeworld Date: Tue, 25 Aug 2020 19:17:06 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20linting=20errors=20and=20s?= =?UTF-8?q?witch=20to=20disable-all=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lint errors source: https://github.com/makeworld-the-better-one/amfora/actions/runs/224352889 --- .github/workflows/golangci-lint.yml | 3 +-- bookmarks/bookmarks.go | 10 +++++----- display/display.go | 2 +- display/download.go | 2 +- display/private.go | 11 +++++++---- display/tab.go | 6 +++--- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d5eb391..00fe13f 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -13,7 +13,6 @@ jobs: version: v1.30 # Optional: golangci-lint command line arguments. - args: --exclude-use-default --enable-all -D asciicheck -D depguard -D dogsled -D funlen -D gci -D gochecknoglobals -D gochecknoinits -D gocognit -D gocyclo -D godot -D godox -D goheader -D gomodguard -D nlreturn -D noctx -D bodyclose -D rowserrcheck -D sqlclosecheck -D stylecheck -D testpackage -D wsl - + args: --exclude-use-default --disable-all -E deadcode -E errcheck -E gosimple -E govet -E ineffassign -E staticcheck -E structcheck -E typecheck -E unused -E varcheck -E dupl -E exhaustive -E exportloopref -E goconst -E gocritic -E goerr113 -E gofmt -E gofumpt -E goimports -E golint -E gomnd -E goprintffuncname -E gosec -E interfacer -E lll -E maligned -E misspell -E nakedret -E nestif -E nolintlint -E prealloc -E scopelint -E unconvert -E unparam -E whitespace # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true diff --git a/bookmarks/bookmarks.go b/bookmarks/bookmarks.go index bd22600..194c357 100644 --- a/bookmarks/bookmarks.go +++ b/bookmarks/bookmarks.go @@ -19,7 +19,7 @@ func bkmkKey(url string) string { func Set(url, name string) { bkmkStore.Set(bkmkKey(url), name) - bkmkStore.WriteConfig() + bkmkStore.WriteConfig() //nolint:errcheck } // Get returns the NAME of the bookmark, given the URL. @@ -33,7 +33,7 @@ func Remove(url string) { // XXX: Viper can't actually delete keys, which means the bookmarks file might get clouded // with non-entries over time. bkmkStore.Set(bkmkKey(url), "") - bkmkStore.WriteConfig() + bkmkStore.WriteConfig() //nolint:errcheck } // All returns all the bookmarks in a map of URLs to names. @@ -48,9 +48,9 @@ func All() (map[string]string, []string) { return bkmks, []string{} } - inverted := make(map[string]string) // Holds inverted map, name->URL - var names []string // Holds bookmark names, for sorting - var keys []string // Final sorted keys (URLs), for returning at the end + inverted := make(map[string]string) // Holds inverted map, name->URL + names := make([]string, 0, len(bkmksMap)) // Holds bookmark names, for sorting + keys := make([]string, 0, len(bkmksMap)) // Final sorted keys (URLs), for returning at the end for b32Url, name := range bkmksMap { if n, ok := name.(string); n == "" || !ok { diff --git a/display/display.go b/display/display.go index 58cada1..34ed79c 100644 --- a/display/display.go +++ b/display/display.go @@ -529,7 +529,7 @@ func Reload() { func URL(u string) { // Some code is copied in followLink() - if u == "about:bookmarks" { + if u == "about:bookmarks" { //nolint:goconst Bookmarks(tabs[curTab]) tabs[curTab].addToHistory("about:bookmarks") return diff --git a/display/download.go b/display/download.go index 2f2f783..6a34054 100644 --- a/display/download.go +++ b/display/download.go @@ -142,7 +142,7 @@ func downloadURL(u string, resp *gemini.Response) { progressbar.OptionShowCount(), progressbar.OptionSpinnerType(14), ) - bar.RenderBlank() + bar.RenderBlank() //nolint:errcheck savePath, err := downloadNameFromURL(u, "") if err != nil { diff --git a/display/private.go b/display/private.go index 355e56c..55b3f41 100644 --- a/display/private.go +++ b/display/private.go @@ -70,15 +70,18 @@ func reformatPage(p *structs.Page) { return } + // TODO: Setup a renderer.RenderFromMediatype func so this isn't needed + var rendered string - if p.Mediatype == structs.TextGemini { + switch p.Mediatype { + case structs.TextGemini: // Links are not recorded because they won't change rendered, _ = renderer.RenderGemini(p.Raw, textWidth(), leftMargin()) - } else if p.Mediatype == structs.TextPlain { + case structs.TextPlain: rendered = renderer.RenderPlainText(p.Raw, leftMargin()) - } else if p.Mediatype == structs.TextAnsi { + case structs.TextAnsi: rendered = renderer.RenderANSI(p.Raw, leftMargin()) - } else { + default: // Rendering this type is not implemented return } diff --git a/display/tab.go b/display/tab.go index 2848cf0..3188646 100644 --- a/display/tab.go +++ b/display/tab.go @@ -68,7 +68,7 @@ func makeNewTab() *tab { return } - if len(tabs[tab].page.Links) <= 0 { + if len(tabs[tab].page.Links) == 0 { // No links on page return } @@ -85,7 +85,7 @@ func makeNewTab() *tab { followLink(tabs[tab], tabs[tab].page.Url, tabs[tab].page.Links[linkN]) return } - if len(currentSelection) <= 0 && (key == tcell.KeyEnter || key == tcell.KeyTab) { + if len(currentSelection) == 0 && (key == tcell.KeyEnter || key == tcell.KeyTab) { // They've started link highlighting tabs[tab].page.Mode = structs.ModeLinkSelect @@ -102,7 +102,7 @@ func makeNewTab() *tab { // There's still a selection, but a different key was pressed, not Enter index, _ := strconv.Atoi(currentSelection[0]) - if key == tcell.KeyTab { + if key == tcell.KeyTab { //nolint:gocritic index = (index + 1) % numSelections } else if key == tcell.KeyBacktab { index = (index - 1 + numSelections) % numSelections