@@ -25,16 +25,15 @@ COMMA := ,
2525
2626XGO_VERSION  := go-1.20.x
2727
28- AIR_PACKAGE  ?= github.com/cosmtrek/
[email protected] 29- EDITORCONFIG_CHECKER_PACKAGE  ?= github.com/editorconfig-checker/editorconfig-checker/cmd/
[email protected] 30- ERRCHECK_PACKAGE  ?= github.com/kisielk/
[email protected] 31- GOFUMPT_PACKAGE  ?= mvdan.cc/
[email protected] 32- GOLANGCI_LINT_PACKAGE  ?= github.com/golangci/golangci-lint/cmd/
[email protected] 33- GXZ_PAGAGE  ?= github.com/ulikunitz/xz/cmd/
[email protected] 28+ AIR_PACKAGE  ?= github.com/cosmtrek/
[email protected] 29+ EDITORCONFIG_CHECKER_PACKAGE  ?= github.com/editorconfig-checker/editorconfig-checker/cmd/
[email protected] 30+ GOFUMPT_PACKAGE  ?= mvdan.cc/
[email protected] 31+ GOLANGCI_LINT_PACKAGE  ?= github.com/golangci/golangci-lint/cmd/
[email protected] 32+ GXZ_PAGAGE  ?= github.com/ulikunitz/xz/cmd/
[email protected] 3433MISSPELL_PACKAGE  ?= github.com/client9/misspell/cmd/
[email protected] 3534SWAGGER_PACKAGE  ?= github.com/go-swagger/go-swagger/cmd/
[email protected] 3635XGO_PACKAGE  ?= src.techknowlogick.com/xgo@latest
37- GO_LICENSES_PACKAGE  ?= github.com/google/go-licenses@v1.5 .0
36+ GO_LICENSES_PACKAGE  ?= github.com/google/go-licenses@v1.6 .0
3837GOVULNCHECK_PACKAGE  ?= golang.org/x/vuln/cmd/govulncheck@latest
3938
4039DOCKER_IMAGE  ?= gitea/gitea
@@ -194,9 +193,20 @@ help:
194193	@echo "  - deps-backend                     install backend dependencies" 
195194	@echo "  - deps-tools                       install tool dependencies" 
196195	@echo "  - lint                             lint everything" 
196+ 	@echo "  - lint-fix                         lint everything and fix issues" 
197197	@echo "  - lint-frontend                    lint frontend files" 
198+ 	@echo "  - lint-frontend-fix                lint frontend files and fix issues" 
198199	@echo "  - lint-backend                     lint backend files" 
200+ 	@echo "  - lint-backend-fix                 lint backend files and fix issues" 
201+ 	@echo "  - lint-go                          lint go files" 
202+ 	@echo "  - lint-go-fix                      lint go files and fix issues" 
203+ 	@echo "  - lint-go-vet                      lint go files with vet" 
204+ 	@echo "  - lint-js                          lint js files" 
205+ 	@echo "  - lint-js-fix                      lint js files and fix issues" 
206+ 	@echo "  - lint-css                         lint css files" 
207+ 	@echo "  - lint-css-fix                     lint css files and fix issues" 
199208	@echo "  - lint-md                          lint markdown files" 
209+ 	@echo "  - lint-swagger                     lint swagger files" 
200210	@echo "  - checks                           run various consistency checks" 
201211	@echo "  - checks-frontend                  check frontend files" 
202212	@echo "  - checks-backend                   check backend files" 
@@ -214,9 +224,7 @@ help:
214224	@echo "  - generate-manpage                 generate manpage" 
215225	@echo "  - generate-swagger                 generate the swagger spec from code comments" 
216226	@echo "  - swagger-validate                 check if the swagger spec is valid" 
217- 	@echo "  - golangci-lint                    run golangci-lint linter" 
218227	@echo "  - go-licenses                      regenerate go licenses" 
219- 	@echo "  - vet                              examines Go source code and reports suspicious constructs" 
220228	@echo "  - tidy                             run go mod tidy" 
221229	@echo "  - test[\#TestSpecificName]    	    run unit test" 
222230	@echo "  - test-sqlite[\#TestSpecificName]  run integration test for sqlite" 
@@ -286,12 +294,6 @@ fmt-check: fmt
286294misspell-check :
287295	go run $(MISSPELL_PACKAGE )  -error $(GO_DIRS )  $(WEB_DIRS ) 
288296
289- .PHONY : vet
290- vet :
291- 	@echo " Running go vet..." 
292- 	@GOOS= GOARCH= $(GO )  build code.gitea.io/gitea-vet
293- 	@$(GO )  vet -vettool=gitea-vet $(GO_PACKAGES ) 
294- 
295297.PHONY : $(TAGS_EVIDENCE ) 
296298$(TAGS_EVIDENCE )  :
297299	@mkdir -p $(MAKE_EVIDENCE_DIR ) 
@@ -324,11 +326,6 @@ swagger-validate:
324326	$(GO )  run $(SWAGGER_PACKAGE )  validate ' ./$(SWAGGER_SPEC)' 
325327	$(SED_INPLACE )  ' $(SWAGGER_SPEC_S_TMPL)'   ' ./$(SWAGGER_SPEC)' 
326328
327- .PHONY : errcheck
328- errcheck :
329- 	@echo " Running errcheck..." 
330- 	$(GO )  run $(ERRCHECK_PACKAGE )  $(GO_PACKAGES ) 
331- 
332329.PHONY : checks
333330checks : checks-frontend checks-backend
334331
@@ -341,18 +338,69 @@ checks-backend: tidy-check swagger-check fmt-check misspell-check swagger-valida
341338.PHONY : lint
342339lint : lint-frontend lint-backend
343340
341+ .PHONY : lint-fix
342+ lint-fix : lint-frontend-fix lint-backend-fix
343+ 
344344.PHONY : lint-frontend
345- lint-frontend : node_modules lint-md
345+ lint-frontend : lint-js lint-css lint-md lint-swagger
346+ 
347+ .PHONY : lint-frontend-fix
348+ lint-frontend-fix : lint-js-fix lint-css-fix lint-md lint-swagger
349+ 
350+ .PHONY : lint-backend
351+ lint-backend : lint-go lint-go-vet lint-editorconfig
352+ 
353+ .PHONY : lint-backend-fix
354+ lint-backend-fix : lint-go-fix lint-go-vet lint-editorconfig
355+ 
356+ .PHONY : lint-js
357+ lint-js : node_modules
346358	npx eslint --color --max-warnings=0 --ext js,vue web_src/js build * .config.js docs/assets/js tests/e2e
359+ 
360+ .PHONY : lint-js-fix
361+ lint-js-fix : node_modules
362+ 	npx eslint --color --max-warnings=0 --ext js,vue web_src/js build * .config.js docs/assets/js tests/e2e --fix
363+ 
364+ .PHONY : lint-css
365+ lint-css : node_modules
347366	npx stylelint --color --max-warnings=0 web_src/css
367+ 
368+ .PHONY : lint-css-fix
369+ lint-css-fix : node_modules
370+ 	npx stylelint --color --max-warnings=0 web_src/css --fix
371+ 
372+ .PHONY : lint-swagger
373+ lint-swagger : node_modules
348374	npx spectral lint -q -F hint $(SWAGGER_SPEC ) 
349375
350376.PHONY : lint-md
351377lint-md : node_modules
352378	npx markdownlint docs * .md
353379
354- .PHONY : lint-backend
355- lint-backend : golangci-lint vet editorconfig-checker
380+ .PHONY : lint-go
381+ lint-go :
382+ 	$(GO )  run $(GOLANGCI_LINT_PACKAGE )  run
383+ 
384+ .PHONY : lint-go-fix
385+ lint-go-fix :
386+ 	$(GO )  run $(GOLANGCI_LINT_PACKAGE )  run --fix
387+ 
388+ #  workaround step for the lint-backend-windows CI task because 'go run' can not
389+ #  have distinct GOOS/GOARCH for its build and run steps
390+ .PHONY : lint-go-windows
391+ lint-go-windows :
392+ 	@GOOS= GOARCH= $(GO )  install $(GOLANGCI_LINT_PACKAGE ) 
393+ 	golangci-lint run
394+ 
395+ .PHONY : lint-go-vet
396+ lint-go-vet :
397+ 	@echo " Running go vet..." 
398+ 	@GOOS= GOARCH= $(GO )  build code.gitea.io/gitea-vet
399+ 	@$(GO )  vet -vettool=gitea-vet $(GO_PACKAGES ) 
400+ 
401+ .PHONY : lint-editorconfig
402+ lint-editorconfig :
403+ 	$(GO )  run $(EDITORCONFIG_CHECKER_PACKAGE )  templates
356404
357405.PHONY : watch
358406watch :
@@ -843,7 +891,6 @@ deps-backend:
843891deps-tools :
844892	$(GO )  install $(AIR_PACKAGE ) 
845893	$(GO )  install $(EDITORCONFIG_CHECKER_PACKAGE ) 
846- 	$(GO )  install $(ERRCHECK_PACKAGE ) 
847894	$(GO )  install $(GOFUMPT_PACKAGE ) 
848895	$(GO )  install $(GOLANGCI_LINT_PACKAGE ) 
849896	$(GO )  install $(GXZ_PAGAGE ) 
@@ -942,21 +989,6 @@ generate-manpage:
942989	@gzip -9 man/man1/gitea.1 &&  echo  man/man1/gitea.1.gz created
943990	@# TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
944991
945- .PHONY : golangci-lint
946- golangci-lint :
947- 	$(GO )  run $(GOLANGCI_LINT_PACKAGE )  run
948- 
949- #  workaround step for the lint-backend-windows CI task because 'go run' can not
950- #  have distinct GOOS/GOARCH for its build and run steps
951- .PHONY : golangci-lint-windows
952- golangci-lint-windows :
953- 	@GOOS= GOARCH= $(GO )  install $(GOLANGCI_LINT_PACKAGE ) 
954- 	golangci-lint run
955- 
956- .PHONY : editorconfig-checker
957- editorconfig-checker :
958- 	$(GO )  run $(EDITORCONFIG_CHECKER_PACKAGE )  templates
959- 
960992.PHONY : docker
961993docker :
962994	docker build --disable-content-trust=false -t $(DOCKER_REF )  . 
0 commit comments