Move checks to common package and add Makefile

Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
jolheiser 2020-04-03 22:28:55 -05:00
parent 23910383a6
commit 6c7b81d401
No known key found for this signature in database
GPG Key ID: B853ADA5DA7BBF7A
4 changed files with 18 additions and 13 deletions

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
.PHONY: build
build:
go build
.PHONY: fmt
fmt:
go fmt ./...

View File

@ -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 {

View File

@ -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")

View File

@ -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,
)
}