Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: latest

Expand All @@ -310,7 +310,7 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
Expand All @@ -324,7 +324,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
Expand All @@ -340,7 +340,7 @@ jobs:

- name: Setup Go (if needed)
if: ${{ needs.discover.outputs.has_go == 'true' }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: go.mod

Expand Down Expand Up @@ -410,7 +410,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version-file: go.mod

Expand Down
13 changes: 0 additions & 13 deletions .golangci.yml

This file was deleted.

7 changes: 1 addition & 6 deletions authHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func UserLogoutAction(w http.ResponseWriter, r *http.Request) error {
return fmt.Errorf("session.Save Error: %w", err)
}

data.CoreData.UserRef = ""
data.UserRef = ""

return nil
}
Expand Down Expand Up @@ -106,11 +106,6 @@ func LoginWithProvider(w http.ResponseWriter, r *http.Request) error {

func Oauth2CallbackPage(w http.ResponseWriter, r *http.Request) error {

type ErrorData struct {
*CoreData
Error string
}

session, err := getSession(w, r)
if session, err = sanitizeSession(w, r, session, err); err != nil {
return fmt.Errorf("session error: %w", err)
Expand Down
6 changes: 0 additions & 6 deletions autoRefreshPage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@ func TaskDoneAutoRefreshPage(w http.ResponseWriter, r *http.Request) error {
}
return nil
}

func taskRedirectWithoutQueryArgs(w http.ResponseWriter, r *http.Request) {
u := r.URL
u.RawQuery = ""
http.Redirect(w, r, u.String(), http.StatusSeeOther)
}
2 changes: 1 addition & 1 deletion bookmarkTabEdit.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func ReplaceTabByIndex(bookmarks string, idx int, newName, newText string) (stri
end := starts[idx+1]

var replacement []string
includeHeader := !(idx == 0 && newName == "")
includeHeader := idx != 0 || newName != ""
if includeHeader {
if newName != "" {
replacement = append(replacement, "Tab: "+newName)
Expand Down
48 changes: 24 additions & 24 deletions bookmarkTabEdit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ func TestExtractTab(t *testing.T) {
}

func TestExtractTabError(t *testing.T) {
if _, err := ExtractTab(tabBookmarkText, "X"); err == nil {
t.Fatalf("expected error")
}
if _, err := ExtractTab(tabBookmarkText, "X"); err == nil {
t.Fatalf("expected error")
}
}

func TestExtractTabByIndex(t *testing.T) {
got, err := ExtractTabByIndex(tabBookmarkWithoutHeader, 0)
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
expected := "Category: A\n--"
if got != expected {
t.Fatalf("expected %q got %q", expected, got)
}
got, err := ExtractTabByIndex(tabBookmarkWithoutHeader, 0)
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
expected := "Category: A\n--"
if got != expected {
t.Fatalf("expected %q got %q", expected, got)
}
}

func TestReplaceTab(t *testing.T) {
Expand All @@ -55,20 +55,20 @@ func TestReplaceTab(t *testing.T) {
}

func TestAppendTab(t *testing.T) {
updated := AppendTab("Category: X", "New", "Category: Y")
expected := "Category: X\nTab: New\nCategory: Y\n"
if updated != expected {
t.Fatalf("expected %q got %q", expected, updated)
}
updated := AppendTab("Category: X", "New", "Category: Y")
expected := "Category: X\nTab: New\nCategory: Y\n"
if updated != expected {
t.Fatalf("expected %q got %q", expected, updated)
}
}

func TestReplaceTabByIndex(t *testing.T) {
updated, err := ReplaceTabByIndex(tabBookmarkWithoutHeader, 0, "", "Category: Z")
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
expected := "Category: Z\nTab: Two\nCategory: B\n"
if updated != expected {
t.Fatalf("expected %q got %q", expected, updated)
}
updated, err := ReplaceTabByIndex(tabBookmarkWithoutHeader, 0, "", "Category: Z")
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
expected := "Category: Z\nTab: Two\nCategory: B\n"
if updated != expected {
t.Fatalf("expected %q got %q", expected, updated)
}
}
8 changes: 4 additions & 4 deletions bookmark_methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestAddTab(t *testing.T) {
p := &BookmarkPage{Blocks: []*BookmarkBlock{{Columns: []*BookmarkColumn{{}}}}}
p.Blocks[0].Columns[0].AddCategory(&BookmarkCategory{Name: "C"})
nl.AddPage(p)
var list BookmarkList = tabs
list := tabs
list.AddTab(nl)
got := list.String()
if got != addTabExpected {
Expand All @@ -133,7 +133,7 @@ func TestInsertTab(t *testing.T) {
p := &BookmarkPage{Blocks: []*BookmarkBlock{{Columns: []*BookmarkColumn{{}}}}}
p.Blocks[0].Columns[0].AddCategory(&BookmarkCategory{Name: "X"})
nl.AddPage(p)
var list BookmarkList = tabs
list := tabs
list.InsertTab(1, nl)
got := list.String()
if got != insertTabExpected {
Expand All @@ -143,7 +143,7 @@ func TestInsertTab(t *testing.T) {

func TestSwitchTab(t *testing.T) {
tabs := ParseBookmarks(switchTabInput)
var list BookmarkList = tabs
list := tabs
list.SwitchTabs(0, 1)
got := list.String()
if got != switchTabExpected {
Expand All @@ -153,7 +153,7 @@ func TestSwitchTab(t *testing.T) {

func TestMoveTab(t *testing.T) {
tabs := ParseBookmarks(switchTabInput)
var list BookmarkList = tabs
list := tabs
list.MoveTab(0, 1)
got := list.String()
if got != switchTabExpected {
Expand Down
20 changes: 1 addition & 19 deletions bookmark_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ type BookmarkTab struct {

func (t *BookmarkTab) stringWithContext(first bool) string {
var sb strings.Builder
if !(first && t.Name == "") {
if !first || t.Name != "" {
if t.Name != "" {
sb.WriteString("Tab: ")
sb.WriteString(t.Name)
Expand Down Expand Up @@ -562,21 +562,3 @@ func FindPageBySha(tabs BookmarkList, sha string) *BookmarkPage {
}
return nil
}

// indexAfterColumn returns the global index after the last category in the specified column.
func indexAfterColumn(tabs BookmarkList, page *BookmarkPage, colIdx int) int {
idx := 0
for _, t := range tabs {
for _, p := range t.Pages {
for _, b := range p.Blocks {
for ci, col := range b.Columns {
idx += len(col.Categories)
if p == page && ci == colIdx {
return idx
}
}
}
}
}
return idx
}
2 changes: 1 addition & 1 deletion cmd/gobookmarks/db_reset_password_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"flag"
"fmt"

. "github.com/arran4/gobookmarks"
. "github.com/arran4/gobookmarks" //nolint:staticcheck
)

type DbResetPasswordCommand struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/gobookmarks/db_users_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"flag"
"fmt"

. "github.com/arran4/gobookmarks"
. "github.com/arran4/gobookmarks" //nolint:staticcheck
)

type DbUsersCommand struct {
Expand Down Expand Up @@ -57,14 +57,14 @@
printHelp(c, err)
return err
}
defer db.Close()
defer func() { _ = db.Close() }()

rows, err := db.Query("SELECT user FROM passwords")
if err != nil {
printHelp(c, err)
return err
}
defer rows.Close()

Check failure on line 67 in cmd/gobookmarks/db_users_command.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `rows.Close` is not checked (errcheck)

for rows.Next() {
var user string
Expand Down
2 changes: 1 addition & 1 deletion cmd/gobookmarks/help_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (c *HelpCommand) Execute(args []string) error {
}
}
}
c.FlagSet().Parse(args)
_ = c.FlagSet().Parse(args)
c.FlagSet().Usage = func() {}
printHelp(target, nil)
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/gobookmarks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"os"

. "github.com/arran4/gobookmarks"
. "github.com/arran4/gobookmarks" //nolint:staticcheck
)

var (
Expand Down
40 changes: 19 additions & 21 deletions cmd/gobookmarks/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"errors"
"flag"
"fmt"
. "github.com/arran4/gobookmarks"

Check failure on line 16 in cmd/gobookmarks/serve.go

View workflow job for this annotation

GitHub Actions / lint

ST1001: should not use dot imports (staticcheck)
"github.com/arran4/gorillamuxlogic"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
Expand All @@ -37,28 +37,28 @@
parent Command
Flags *flag.FlagSet

GithubClientID stringFlag
GithubSecret stringFlag
GitlabClientID stringFlag
GitlabSecret stringFlag
ExternalURL stringFlag
Namespace stringFlag
Title stringFlag
GithubClientID stringFlag
GithubSecret stringFlag
GitlabClientID stringFlag
GitlabSecret stringFlag
ExternalURL stringFlag
Namespace stringFlag
Title stringFlag
FaviconCacheDir stringFlag
FaviconCacheSize stringFlag
FaviconMaxCacheCount stringFlag
CommitsPerPage stringFlag
GithubServer stringFlag
GitlabServer stringFlag
LocalGitPath stringFlag
DbProvider stringFlag
DbConn stringFlag
SessionKey stringFlag
ProviderOrder stringFlag
CssColumns boolFlag
NoFooter boolFlag
DevMode boolFlag
DumpConfig boolFlag
GitlabServer stringFlag
LocalGitPath stringFlag
DbProvider stringFlag
DbConn stringFlag
SessionKey stringFlag
ProviderOrder stringFlag
CssColumns boolFlag
NoFooter boolFlag
DevMode boolFlag
DumpConfig boolFlag
}

func (rc *RootCommand) NewServeCommand() (*ServeCommand, error) {
Expand Down Expand Up @@ -452,7 +452,7 @@
if err != nil {
log.Fatalf("Failed to create cert.pem file: %v", err)
}
defer certFile.Close()
defer func() { _ = certFile.Close() }()
if err := pem.Encode(certFile, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}); err != nil {
log.Fatalf("Failed to write data to cert.pem: %v", err)
}
Expand All @@ -461,7 +461,7 @@
if err != nil {
log.Fatalf("Failed to create key.pem file: %v", err)
}
defer keyFile.Close()
defer func() { _ = keyFile.Close() }()
privBytes, err := x509.MarshalECPrivateKey(priv)
if err != nil {
log.Fatalf("Failed to marshal private key: %v", err)
Expand All @@ -477,8 +477,6 @@
switch each := each.(type) {
case http.Handler:
each.ServeHTTP(w, r)
case http.HandlerFunc:
each(w, r)
case func(http.ResponseWriter, *http.Request):
each(w, r)
case func(http.ResponseWriter, *http.Request) error:
Expand Down
Loading
Loading