diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5305662 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: build +build: + go build + +.PHONY: fmt +fmt: + go fmt ./... \ No newline at end of file diff --git a/imports/imports.go b/checks/imports.go similarity index 87% rename from imports/imports.go rename to checks/imports.go index 400a2b4..6ef5975 100644 --- a/imports/imports.go +++ b/checks/imports.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package imports +package checks import ( "strings" @@ -10,13 +10,13 @@ import ( "golang.org/x/tools/go/analysis" ) -var Analyzer = &analysis.Analyzer{ +var Imports = &analysis.Analyzer{ Name: "imports", Doc: "check for import order.", - Run: run, + Run: runImports, } -func run(pass *analysis.Pass) (interface{}, error) { +func runImports(pass *analysis.Pass) (interface{}, error) { for _, file := range pass.Files { level := 0 for _, im := range file.Imports { diff --git a/license/license.go b/checks/license.go similarity index 92% rename from license/license.go rename to checks/license.go index 03c201e..83f9e3c 100644 --- a/license/license.go +++ b/checks/license.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package license +package checks import ( "regexp" @@ -17,13 +17,13 @@ var ( buildTag = "// +build" ) -var Analyzer = &analysis.Analyzer{ +var License = &analysis.Analyzer{ Name: "license", Doc: "check for a copyright header.", - Run: run, + Run: runLicense, } -func run(pass *analysis.Pass) (interface{}, error) { +func runLicense(pass *analysis.Pass) (interface{}, error) { for _, file := range pass.Files { if len(file.Comments) == 0 { pass.Reportf(file.Pos(), "Copyright not found") diff --git a/main.go b/main.go index e9cc9d9..9b8b000 100644 --- a/main.go +++ b/main.go @@ -5,15 +5,13 @@ package main import ( + "gitea.com/jolheiser/gitea-vet/checks" "golang.org/x/tools/go/analysis/unitchecker" - - "gitea.com/jolheiser/gitea-vet/imports" - "gitea.com/jolheiser/gitea-vet/license" ) func main() { unitchecker.Main( - license.Analyzer, - imports.Analyzer, + checks.Imports, + checks.License, ) }