summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2025-02-07 23:43:09 +0700
committerShulhan <ms@kilabit.info>2025-02-07 23:43:20 +0700
commit49e7143dbad57a48115fdd299b42ab8e66f6d7cc (patch)
tree20e4cac969070b79e7849f8f3ca813eb64233226
parent30971348166edbe386beb98a7222d70590cea6fc (diff)
downloadawwan-49e7143dbad57a48115fdd299b42ab8e66f6d7cc.tar.xz
internal/cmd/gocheck: internal linters
The fieldalignment and shadow is a linter from golang.org/x/tools. This program actually have an API that can be used. The pakakeh.go/lib/goanalysis wrap those APIs into a single function call that can be run inside a main. This minimize and simplified our tools dependencies.
-rw-r--r--Makefile3
-rw-r--r--http_server_test.go10
-rw-r--r--internal/cmd/gocheck/main.go17
3 files changed, 20 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index f2f2ae7..46f5438 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,7 @@ test:
.PHONY: lint
lint:
- -fieldalignment ./...
- -shadow ./...
+ go run ./internal/cmd/gocheck ./...
go vet ./...
## embed convert the TypeScript files into JavaScript and embed all _wui
diff --git a/http_server_test.go b/http_server_test.go
index 2dcd94f..8617c65 100644
--- a/http_server_test.go
+++ b/http_server_test.go
@@ -55,10 +55,7 @@ func TestHttpServer_Decrypt(t *testing.T) {
}
var endpointDecrypt = &libhttp.Endpoint{
- Method: libhttp.RequestMethodPost,
- Path: pathAwwanAPIDecrypt,
- RequestType: libhttp.RequestTypeJSON,
- ResponseType: libhttp.ResponseTypeJSON,
+ Path: pathAwwanAPIDecrypt,
}
var cases = []testCase{{
@@ -142,10 +139,7 @@ func TestHttpServer_Encrypt(t *testing.T) {
}
var endpointEncrypt = &libhttp.Endpoint{
- Method: libhttp.RequestMethodPost,
- Path: pathAwwanAPIEncrypt,
- RequestType: libhttp.RequestTypeJSON,
- ResponseType: libhttp.ResponseTypeJSON,
+ Path: pathAwwanAPIEncrypt,
}
var cases = []testCase{{
diff --git a/internal/cmd/gocheck/main.go b/internal/cmd/gocheck/main.go
new file mode 100644
index 0000000..956e790
--- /dev/null
+++ b/internal/cmd/gocheck/main.go
@@ -0,0 +1,17 @@
+// SPDX-FileCopyrightText: 2024 M. Shulhan <ms@kilabit.info>
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+// Program gocheck implement go static analysis using [Analyzer] that are not
+// included in the default go vet.
+// See package [lib/goanalysis] for more information.
+//
+// [Analyzer]: https://pkg.go.dev/golang.org/x/tools/go/analysis#hdr-Analyzer
+// [lib/goanalysis]: https://pkg.go.dev/git.sr.ht/~shulhan/pakakeh.go/lib/goanalysis/
+package main
+
+import "git.sr.ht/~shulhan/pakakeh.go/lib/goanalysis"
+
+func main() {
+ goanalysis.Check()
+}