mirror of
https://github.com/makew0rld/amfora.git
synced 2024-09-25 22:55:55 -04:00
🚨 More linting fixes and unix build fix
This commit is contained in:
parent
e4279de417
commit
6853bb9c6d
2
.github/workflows/golangci-lint.yml
vendored
2
.github/workflows/golangci-lint.yml
vendored
@ -13,6 +13,6 @@ jobs:
|
|||||||
version: v1.30
|
version: v1.30
|
||||||
|
|
||||||
# Optional: golangci-lint command line arguments.
|
# 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`.
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
|
@ -14,4 +14,9 @@ script:
|
|||||||
env:
|
env:
|
||||||
GO111MODULE=on
|
GO111MODULE=on
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.cache/go-build
|
||||||
|
- $GOPATH/pkg/mod
|
||||||
|
|
||||||
# TODO: GitHub Releases deploy
|
# TODO: GitHub Releases deploy
|
||||||
|
6
cache/cache.go
vendored
6
cache/cache.go
vendored
@ -33,7 +33,7 @@ func removeIndex(s []string, i int) []string {
|
|||||||
return s[:len(s)-1]
|
return s[:len(s)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeUrl(url string) {
|
func removeURL(url string) {
|
||||||
for i := range urls {
|
for i := range urls {
|
||||||
if urls[i] == url {
|
if urls[i] == url {
|
||||||
urls = removeIndex(urls, i)
|
urls = removeIndex(urls, i)
|
||||||
@ -73,7 +73,7 @@ func AddPage(p *structs.Page) {
|
|||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
pages[p.URL] = p
|
pages[p.URL] = p
|
||||||
// Remove the URL if it was already there, then add it to the end
|
// 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)
|
urls = append(urls, p.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ func RemovePage(url string) {
|
|||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
delete(pages, url)
|
delete(pages, url)
|
||||||
removeUrl(url)
|
removeURL(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearPages removes all pages from the cache.
|
// ClearPages removes all pages from the cache.
|
||||||
|
1
cache/cache_test.go
vendored
1
cache/cache_test.go
vendored
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
var p = structs.Page{URL: "example.com"}
|
var p = structs.Page{URL: "example.com"}
|
||||||
var p2 = structs.Page{URL: "example.org"}
|
var p2 = structs.Page{URL: "example.org"}
|
||||||
var queryPage = structs.Page{URL: "gemini://example.com/test?query"}
|
|
||||||
|
|
||||||
func reset() {
|
func reset() {
|
||||||
ClearPages()
|
ClearPages()
|
||||||
|
@ -23,20 +23,21 @@ var tofuDBDir string
|
|||||||
var tofuDBPath string
|
var tofuDBPath string
|
||||||
|
|
||||||
// Bookmarks
|
// Bookmarks
|
||||||
|
|
||||||
var BkmkStore = viper.New()
|
var BkmkStore = viper.New()
|
||||||
var bkmkDir string
|
var bkmkDir string
|
||||||
var bkmkPath string
|
var bkmkPath string
|
||||||
|
|
||||||
// For other pkgs to use
|
|
||||||
var DownloadsDir string
|
var DownloadsDir string
|
||||||
|
|
||||||
|
//nolint:golint,goerr113
|
||||||
func Init() error {
|
func Init() error {
|
||||||
home, err := homedir.Dir()
|
home, err := homedir.Dir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Store AppData path
|
// Store AppData path
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" { //nolint:goconst
|
||||||
appdata, ok := os.LookupEnv("APPDATA")
|
appdata, ok := os.LookupEnv("APPDATA")
|
||||||
if ok {
|
if ok {
|
||||||
amforaAppData = filepath.Join(appdata, "amfora")
|
amforaAppData = filepath.Join(appdata, "amfora")
|
||||||
@ -179,7 +180,7 @@ func Init() error {
|
|||||||
// Validate path
|
// Validate path
|
||||||
dDir := viper.GetString("a-general.downloads")
|
dDir := viper.GetString("a-general.downloads")
|
||||||
di, err := os.Stat(dDir)
|
di, err := os.Stat(dDir)
|
||||||
if err == nil {
|
if err == nil { //nolint:gocritic
|
||||||
if !di.IsDir() {
|
if !di.IsDir() {
|
||||||
return fmt.Errorf("downloads path specified is not a directory: %s", dDir)
|
return fmt.Errorf("downloads path specified is not a directory: %s", dDir)
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@ func KeyToNum(key rune) (int, error) {
|
|||||||
return i + 1, nil
|
return i + 1, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1, errors.New("provided key is invalid")
|
return -1, errors.New("provided key is invalid") //nolint:goerr113
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,7 @@ func Init() {
|
|||||||
App.SetFocus(tabs[tab].view)
|
App.SetFocus(tabs[tab].view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:exhaustive
|
||||||
switch key {
|
switch key {
|
||||||
case tcell.KeyEnter:
|
case tcell.KeyEnter:
|
||||||
// Figure out whether it's a URL, link number, or search
|
// Figure out whether it's a URL, link number, or search
|
||||||
@ -169,7 +170,8 @@ func Init() {
|
|||||||
} else {
|
} else {
|
||||||
// It's a full URL or search term
|
// It's a full URL or search term
|
||||||
// Detect if it's a search or URL
|
// 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)
|
u := viper.GetString("a-general.search") + "?" + queryEscape(query)
|
||||||
cache.RemovePage(u) // Don't use the cached version of the search
|
cache.RemovePage(u) // Don't use the cached version of the search
|
||||||
URL(u)
|
URL(u)
|
||||||
@ -245,6 +247,7 @@ func Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:exhaustive
|
||||||
switch event.Key() {
|
switch event.Key() {
|
||||||
case tcell.KeyCtrlR:
|
case tcell.KeyCtrlR:
|
||||||
Reload()
|
Reload()
|
||||||
@ -318,8 +321,10 @@ func Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the keys and operations that can work while a tab IS loading
|
// All the keys and operations that can work while a tab IS loading
|
||||||
|
|
||||||
|
//nolint:exhaustive
|
||||||
switch event.Key() {
|
switch event.Key() {
|
||||||
case tcell.KeyCtrlT:
|
case tcell.KeyCtrlT:
|
||||||
if tabs[curTab].page.Mode == structs.ModeLinkSelect {
|
if tabs[curTab].page.Mode == structs.ModeLinkSelect {
|
||||||
|
@ -261,13 +261,12 @@ func getSafeDownloadName(name string, lastDot bool, n int) (string, error) {
|
|||||||
if lastDot {
|
if lastDot {
|
||||||
ext := filepath.Ext(name)
|
ext := filepath.Ext(name)
|
||||||
return strings.TrimSuffix(name, ext) + "(" + strconv.Itoa(n) + ")" + ext
|
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)
|
d, err := os.Open(config.DownloadsDir)
|
||||||
|
@ -268,6 +268,7 @@ func Tofu(host string, expiry time.Time) bool {
|
|||||||
}
|
}
|
||||||
yesNoModal.GetFrame().SetTitle(" TOFU ")
|
yesNoModal.GetFrame().SetTitle(" TOFU ")
|
||||||
yesNoModal.SetText(
|
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? ",
|
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,
|
host,
|
||||||
humanize.Time(expiry),
|
humanize.Time(expiry),
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//nolint
|
||||||
package display
|
package display
|
||||||
|
|
||||||
var newTabContent = `# New Tab
|
var newTabContent = `# New Tab
|
||||||
|
@ -392,8 +392,7 @@ func handleURL(t *tab, u string) (string, bool) {
|
|||||||
// Make another request with the query string added
|
// Make another request with the query string added
|
||||||
// + chars are replaced because PathEscape doesn't do that
|
// + chars are replaced because PathEscape doesn't do that
|
||||||
parsed.RawQuery = queryEscape(userInput)
|
parsed.RawQuery = queryEscape(userInput)
|
||||||
if len(parsed.String()) > 1024 {
|
if len(parsed.String()) > gemini.URLMaxLength {
|
||||||
// 1024 is the max size for URLs in the spec
|
|
||||||
Error("Input Error", "URL for that input would be too long.")
|
Error("Input Error", "URL for that input would be too long.")
|
||||||
return ret("", false)
|
return ret("", false)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// +build linux freebsd netbsd openbsd
|
// +build linux freebsd netbsd openbsd
|
||||||
|
|
||||||
//nolint:goerr113
|
//nolint:goerr113
|
||||||
package webbrowser
|
package webbrowser
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user