Skip to content

Commit bea9b3c

Browse files
committed
Add misspell, gocritic, revive
1 parent affe8a4 commit bea9b3c

20 files changed

Lines changed: 37 additions & 17 deletions

File tree

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@ clean:
2121
test:
2222
stdout=$$(gofumpt -l . 2>&1); if [ "$$stdout" ]; then exit 1; fi
2323
go vet ./...
24+
misspell $(GO_FILES)
2425
gocyclo -over 10 $(GO_FILES)
2526
staticcheck ./...
2627
errcheck ./...
28+
gocritic check -disable='#experimental,#opinionated' -@ifElseChain.minThreshold 3 ./...
29+
revive -set_exit_status ./...
2730
go test -v -cover ./...
2831
gosec -exclude-dir=tests ./...
2932
govulncheck ./...
3033
@printf '\n%s\n' "> Test successful"
3134

3235
.PHONY: setup
3336
setup:
37+
go install github.com/client9/misspell/cmd/misspell@latest
3438
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
39+
go install github.com/go-critic/go-critic/cmd/gocritic@latest
3540
go install github.com/kisielk/errcheck@latest
41+
go install github.com/mgechev/revive@latest
3642
go install github.com/securego/gosec/v2/cmd/gosec@latest
3743
go install golang.org/x/vuln/cmd/govulncheck@latest
3844
go install honnef.co/go/tools/cmd/staticcheck@latest

cmd/pbcli/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main provides the main function as a starting point of this tool.
12
package main
23

34
import (

internal/api/mod.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// Package api provides low-level functionality to interact with the PushBits API.
12
package api
23

34
import (
45
"encoding/json"
6+
"fmt"
57
"io"
68
"net/http"
79
"net/url"
@@ -54,15 +56,15 @@ func Request(base, endpoint, method, proxy, username, password string, hasBody b
5456
if hasBody {
5557
reqBody, err := json.Marshal(data)
5658
if err != nil {
57-
log.Fatal(err)
59+
return nil, err
5860
}
5961

6062
reqBodyReader = strings.NewReader(string(reqBody))
6163
}
6264

6365
req, err := http.NewRequest(method, url.String(), reqBodyReader)
6466
if err != nil {
65-
log.Fatal(err)
67+
return nil, err
6668
}
6769

6870
req.Header.Set("Accept", "application/json")
@@ -77,19 +79,19 @@ func Request(base, endpoint, method, proxy, username, password string, hasBody b
7779
defer handling.Close(resp.Body)
7880

7981
if resp.StatusCode != http.StatusOK {
80-
log.Fatalf("Request failed with HTTP %s.", resp.Status)
82+
return nil, fmt.Errorf("request failed with HTTP %s", resp.Status)
8183
}
8284

8385
bodyText, err := io.ReadAll(resp.Body)
8486
if err != nil {
85-
log.Fatal(err)
87+
return nil, err
8688
}
8789

8890
var obj interface{}
8991

9092
err = json.Unmarshal(bodyText, &obj)
9193
if err != nil {
92-
log.Fatal(err)
94+
return nil, err
9395
}
9496

9597
return obj, nil

internal/application/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type createCommand struct {
1818
StrictCompatibility bool `long:"compat" help:"Enforce strict compatibility with Gotify"`
1919
}
2020

21-
func (c *createCommand) Run(s *options.Options) error {
21+
func (c *createCommand) Run(_ *options.Options) error {
2222
password := ui.GetCurrentPassword(c.Username)
2323

2424
data := map[string]interface{}{

internal/application/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type deleteCommand struct {
1919
ID uint `arg:"" help:"The ID of the application"`
2020
}
2121

22-
func (c *deleteCommand) Run(s *options.Options) error {
22+
func (c *deleteCommand) Run(_ *options.Options) error {
2323
password := ui.GetCurrentPassword(c.Username)
2424

2525
populatedEndpoint := fmt.Sprintf(deleteEndpoint, c.ID)

internal/application/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type listCommand struct {
1616
options.AuthOptions
1717
}
1818

19-
func (c *listCommand) Run(s *options.Options) error {
19+
func (c *listCommand) Run(_ *options.Options) error {
2020
password := ui.GetCurrentPassword(c.Username)
2121

2222
resp, err := api.Get(c.URL, listEndpoint, c.Proxy, c.Username, password)

internal/application/mod.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package application provides commands related to managing applications.
12
package application
23

34
// Command contains all subcommands provided by this package.

internal/application/show.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type showCommand struct {
1919
ID uint `arg:"" help:"The ID of the application"`
2020
}
2121

22-
func (c *showCommand) Run(s *options.Options) error {
22+
func (c *showCommand) Run(_ *options.Options) error {
2323
password := ui.GetCurrentPassword(c.Username)
2424

2525
populatedEndpoint := fmt.Sprintf(showEndpoint, c.ID)

internal/application/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type updateCommand struct {
2222
StrictCompatibility bool `long:"compat" help:"Enforce strict compatibility with Gotify"`
2323
}
2424

25-
func (c *updateCommand) Run(s *options.Options) error {
25+
func (c *updateCommand) Run(_ *options.Options) error {
2626
password := ui.GetCurrentPassword(c.Username)
2727

2828
if !c.RefreshToken && c.StrictCompatibility {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package buildconfig cpntains variables that are set during compliation.
12
package buildconfig
23

4+
// Version of the build.
35
var Version = "unknown"

0 commit comments

Comments
 (0)