1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-12-04 14:46:29 -05:00

🚨 More linting fixes and unix build fix

This commit is contained in:
makeworld 2020-08-27 11:47:57 -04:00
parent e4279de417
commit 6853bb9c6d
12 changed files with 29 additions and 18 deletions

View File

@ -13,6 +13,6 @@ jobs:
version: v1.30
# Optional: golangci-lint command line arguments.
args: --max-issues-per-linter 0 --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 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
args: --max-issues-per-linter=0 --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 goimports -E golint -E goprintffuncname -E interfacer -E lll -E maligned -E misspell -E nakedret -E nolintlint -E prealloc -E scopelint -E unconvert -E unparam
# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

View File

@ -14,4 +14,9 @@ script:
env:
GO111MODULE=on
cache:
directories:
- $HOME/.cache/go-build
- $GOPATH/pkg/mod
# TODO: GitHub Releases deploy

6
cache/cache.go vendored
View File

@ -33,7 +33,7 @@ func removeIndex(s []string, i int) []string {
return s[:len(s)-1]
}
func removeUrl(url string) {
func removeURL(url string) {
for i := range urls {
if urls[i] == url {
urls = removeIndex(urls, i)
@ -73,7 +73,7 @@ func AddPage(p *structs.Page) {
defer lock.Unlock()
pages[p.URL] = p
// Remove the URL if it was already there, then add it to the end
removeUrl(p.URL)
removeURL(p.URL)
urls = append(urls, p.URL)
}
@ -83,7 +83,7 @@ func RemovePage(url string) {
lock.Lock()
defer lock.Unlock()
delete(pages, url)
removeUrl(url)
removeURL(url)
}
// ClearPages removes all pages from the cache.

1
cache/cache_test.go vendored
View File

@ -9,7 +9,6 @@ import (
var p = structs.Page{URL: "example.com"}
var p2 = structs.Page{URL: "example.org"}
var queryPage = structs.Page{URL: "gemini://example.com/test?query"}
func reset() {
ClearPages()

View File

@ -23,20 +23,21 @@ var tofuDBDir string
var tofuDBPath string
// Bookmarks
var BkmkStore = viper.New()
var bkmkDir string
var bkmkPath string
// For other pkgs to use
var DownloadsDir string
//nolint:golint,goerr113
func Init() error {
home, err := homedir.Dir()
if err != nil {
return err
}
// Store AppData path
if runtime.GOOS == "windows" {
if runtime.GOOS == "windows" { //nolint:goconst
appdata, ok := os.LookupEnv("APPDATA")
if ok {
amforaAppData = filepath.Join(appdata, "amfora")
@ -179,7 +180,7 @@ func Init() error {
// Validate path
dDir := viper.GetString("a-general.downloads")
di, err := os.Stat(dDir)
if err == nil {
if err == nil { //nolint:gocritic
if !di.IsDir() {
return fmt.Errorf("downloads path specified is not a directory: %s", dDir)
}

View File

@ -20,5 +20,5 @@ func KeyToNum(key rune) (int, error) {
return i + 1, nil
}
}
return -1, errors.New("provided key is invalid")
return -1, errors.New("provided key is invalid") //nolint:goerr113
}

View File

@ -114,6 +114,7 @@ func Init() {
App.SetFocus(tabs[tab].view)
}
//nolint:exhaustive
switch key {
case tcell.KeyEnter:
// Figure out whether it's a URL, link number, or search
@ -169,7 +170,8 @@ func Init() {
} else {
// It's a full URL or search term
// Detect if it's a search or URL
if strings.Contains(query, " ") || (!strings.Contains(query, "//") && !strings.Contains(query, ".") && !strings.HasPrefix(query, "about:")) {
if strings.Contains(query, " ") ||
(!strings.Contains(query, "//") && !strings.Contains(query, ".") && !strings.HasPrefix(query, "about:")) {
u := viper.GetString("a-general.search") + "?" + queryEscape(query)
cache.RemovePage(u) // Don't use the cached version of the search
URL(u)
@ -245,6 +247,7 @@ func Init() {
}
}
//nolint:exhaustive
switch event.Key() {
case tcell.KeyCtrlR:
Reload()
@ -318,8 +321,10 @@ func Init() {
}
}
}
// All the keys and operations that can work while a tab IS loading
//nolint:exhaustive
switch event.Key() {
case tcell.KeyCtrlT:
if tabs[curTab].page.Mode == structs.ModeLinkSelect {

View File

@ -261,13 +261,12 @@ func getSafeDownloadName(name string, lastDot bool, n int) (string, error) {
if lastDot {
ext := filepath.Ext(name)
return strings.TrimSuffix(name, ext) + "(" + strconv.Itoa(n) + ")" + ext
} else {
idx := strings.Index(name, ".")
if idx == -1 {
return name + "(" + strconv.Itoa(n) + ")"
}
return name[:idx] + "(" + strconv.Itoa(n) + ")" + name[idx:]
}
idx := strings.Index(name, ".")
if idx == -1 {
return name + "(" + strconv.Itoa(n) + ")"
}
return name[:idx] + "(" + strconv.Itoa(n) + ")" + name[idx:]
}
d, err := os.Open(config.DownloadsDir)

View File

@ -268,6 +268,7 @@ func Tofu(host string, expiry time.Time) bool {
}
yesNoModal.GetFrame().SetTitle(" TOFU ")
yesNoModal.SetText(
//nolint:lll
fmt.Sprintf("%s's certificate has changed, possibly indicating an security issue. The certificate would have expired %s. Are you sure you want to continue? ",
host,
humanize.Time(expiry),

View File

@ -1,3 +1,4 @@
//nolint
package display
var newTabContent = `# New Tab

View File

@ -392,8 +392,7 @@ func handleURL(t *tab, u string) (string, bool) {
// Make another request with the query string added
// + chars are replaced because PathEscape doesn't do that
parsed.RawQuery = queryEscape(userInput)
if len(parsed.String()) > 1024 {
// 1024 is the max size for URLs in the spec
if len(parsed.String()) > gemini.URLMaxLength {
Error("Input Error", "URL for that input would be too long.")
return ret("", false)
}

View File

@ -1,4 +1,5 @@
// +build linux freebsd netbsd openbsd
//nolint:goerr113
package webbrowser