diff --git a/.golangci.yml b/.golangci.yml index 2ad39fbae2c..483843bc55d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -153,6 +153,7 @@ linters: text: '(?i)exitAfterDefer:' paths: - node_modules + - .venv - public - web_src - third_party$ @@ -172,6 +173,7 @@ formatters: generated: lax paths: - node_modules + - .venv - public - web_src - third_party$ diff --git a/Makefile b/Makefile index 3d69fd972e4..e81dab7f6cb 100644 --- a/Makefile +++ b/Makefile @@ -258,7 +258,7 @@ clean: ## delete backend and integration files .PHONY: fmt fmt: ## format the Go and template code - @GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' + @GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run tools/code-batch-process.go gitea-fmt -w '{file-list}' $(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only @# whitespace before it @@ -472,7 +472,7 @@ test\#%: coverage: grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out - $(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all + $(GO) run tools/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all .PHONY: unit-test-coverage unit-test-coverage: diff --git a/eslint.config.ts b/eslint.config.ts index 02aacefca28..d9c4bcae3a6 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -49,6 +49,7 @@ export default defineConfig([ }, linterOptions: { reportUnusedDisableDirectives: 2, + reportUnusedInlineConfigs: 2, }, plugins: { '@eslint-community/eslint-comments': comments, diff --git a/tests/sqlite.ini.tmpl b/tests/sqlite.ini.tmpl index f39888874f9..9d184bce6a7 100644 --- a/tests/sqlite.ini.tmpl +++ b/tests/sqlite.ini.tmpl @@ -114,7 +114,7 @@ ENABLED = true [markup.html] ENABLED = true FILE_EXTENSIONS = .html -RENDER_COMMAND = go run build/test-echo.go +RENDER_COMMAND = go run tools/test-echo.go ;RENDER_COMMAND = cat ;IS_INPUT_FILE = true RENDER_CONTENT_MODE = sanitized diff --git a/build/code-batch-process.go b/tools/code-batch-process.go similarity index 96% rename from build/code-batch-process.go rename to tools/code-batch-process.go index 16d1273d967..2c7ccdf8a6c 100644 --- a/build/code-batch-process.go +++ b/tools/code-batch-process.go @@ -12,6 +12,7 @@ import ( "os/exec" "path/filepath" "regexp" + "slices" "strconv" "strings" @@ -217,15 +218,6 @@ func newFileCollectorFromMainOptions(mainOptions map[string]string) (fc *fileCol return newFileCollector(fileFilter, batchSize) } -func containsString(a []string, s string) bool { - for _, v := range a { - if v == s { - return true - } - } - return false -} - func giteaFormatGoImports(files []string, doWriteFile bool) error { for _, file := range files { if err := codeformat.FormatGoImports(file, doWriteFile); err != nil { @@ -264,10 +256,10 @@ func main() { logVerbose("batch cmd: %s %v", subCmd, substArgs) switch subCmd { case "gitea-fmt": - if containsString(subArgs, "-d") { + if slices.Contains(subArgs, "-d") { log.Print("the -d option is not supported by gitea-fmt") } - cmdErrors = append(cmdErrors, giteaFormatGoImports(files, containsString(subArgs, "-w"))) + cmdErrors = append(cmdErrors, giteaFormatGoImports(files, slices.Contains(subArgs, "-w"))) cmdErrors = append(cmdErrors, passThroughCmd("gofmt", append([]string{"-w", "-r", "interface{} -> any"}, substArgs...))) cmdErrors = append(cmdErrors, passThroughCmd("go", append([]string{"run", os.Getenv("GOFUMPT_PACKAGE"), "-extra"}, substArgs...))) default: diff --git a/build/gocovmerge.go b/tools/gocovmerge.go similarity index 100% rename from build/gocovmerge.go rename to tools/gocovmerge.go diff --git a/build/test-echo.go b/tools/test-echo.go similarity index 100% rename from build/test-echo.go rename to tools/test-echo.go