Check SPDX-License-Identifier #21
@ -1,6 +1,5 @@
|
||||
linters:
|
||||
enable:
|
||||
- deadcode
|
||||
- dogsled
|
||||
- dupl
|
||||
- errcheck
|
||||
@ -9,15 +8,12 @@ linters:
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- golint
|
||||
- revive
|
||||
- gosimple
|
||||
- govet
|
||||
- maligned
|
||||
- misspell
|
||||
- prealloc
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
4
Makefile
4
Makefile
@ -17,6 +17,6 @@ vet: build
|
||||
lint:
|
||||
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
export BINARY="golangci-lint"; \
|
||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(shell $(GO) env GOPATH)/bin v1.24.0; \
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell $(GO) env GOPATH)/bin v1.50.1; \
|
||||
fi
|
||||
golangci-lint run --timeout 5m
|
||||
golangci-lint run --timeout 5m
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package checks
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package checks
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package checks
|
||||
|
||||
@ -12,7 +11,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
header = regexp.MustCompile(`.*Copyright.*\d{4}.*(Gitea|Gogs)`)
|
||||
copyrightRegx = regexp.MustCompile(`.*Copyright.*\d{4}.*(Gitea|Gogs)`)
|
||||
identifierRegx = regexp.MustCompile(`SPDX-License-Identifier: [\w.-]+`)
|
||||
|
||||
goGenerate = "//go:generate"
|
||||
buildTag = "// +build"
|
||||
)
|
||||
@ -58,16 +59,22 @@ func runLicense(pass *analysis.Pass) (interface{}, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
var check bool
|
||||
var copyright, identifier bool
|
||||
for _, comment := range file.Comments[commentGroup].List {
|
||||
if header.MatchString(comment.Text) {
|
||||
check = true
|
||||
if copyrightRegx.MatchString(comment.Text) {
|
||||
copyright = true
|
||||
}
|
||||
if identifierRegx.MatchString(comment.Text) {
|
||||
identifier = true
|
||||
}
|
||||
}
|
||||
|
||||
if !check {
|
||||
if !copyright {
|
||||
pass.Reportf(file.Pos(), "Copyright did not match check")
|
||||
}
|
||||
if !identifier {
|
||||
pass.Reportf(file.Pos(), "SPDX-License-Identifier did not match check")
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package checks
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package checks
|
||||
|
||||
|
3
main.go
3
main.go
@ -1,6 +1,5 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package main
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user