aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/linters.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-12-05 20:46:55 +0100
committerRobin Jarry <robin@jarry.cc>2023-12-14 23:05:07 +0100
commit73bf7241e611ea28e7a58584341921d1262afaa1 (patch)
treede7a87d1c8888d6e4309f5cf06f1a82f9e8ec051 /contrib/linters.go
parent2db657b6bdd6394109c8adc32098d3f39c43f03d (diff)
downloadaerc-73bf7241e611ea28e7a58584341921d1262afaa1.tar.gz
lint,validate: fix for openbsd
- Remove GNU specific stuff (ln -v, mktemp --tempdir, grep --color) - Remove GCC specific flags in sendemail-validate (-Warith-conversion) - Add -std=c99 and -Wpedantic and fix the reported warnings. - Explicitly call gmake everywhere. - Run our custom analyzer standalone. Golangci lint plugins are not supported on OpenBSD. Indirect dependency to golang.org/x/mod is required somehow... Reported-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
Diffstat (limited to 'contrib/linters.go')
-rw-r--r--contrib/linters.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/contrib/linters.go b/contrib/linters.go
index 41655a67..71895e7c 100644
--- a/contrib/linters.go
+++ b/contrib/linters.go
@@ -5,8 +5,10 @@ import (
"go/token"
"go/types"
"reflect"
+ "strings"
"golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/multichecker"
)
type indirectCalls struct {
@@ -71,7 +73,10 @@ func runPanic(pass *analysis.Pass) (interface{}, error) {
}
if !isPanicHandlerInstall(block.List[0]) {
- pass.Report(panicDiag(block.Pos()))
+ path := pass.Fset.File(block.Pos()).Name()
+ if !strings.HasSuffix(path, "_test.go") {
+ pass.Report(panicDiag(block.Pos()))
+ }
}
return true
@@ -85,6 +90,9 @@ func runPanicIndirect(pass *analysis.Pass) (interface{}, error) {
calls := pass.ResultOf[PanicAnalyzer].(*indirectCalls)
for _, file := range pass.Files {
+ if strings.HasSuffix(file.Name.Name, "_test") {
+ continue
+ }
for _, decl := range file.Decls {
if f, ok := decl.(*ast.FuncDecl); ok {
if _, ok := calls.methods[f.Name.Pos()]; ok {
@@ -95,7 +103,10 @@ func runPanicIndirect(pass *analysis.Pass) (interface{}, error) {
continue
}
if !isPanicHandlerInstall(f.Body.List[0]) {
- pass.Report(panicDiag(f.Body.Pos()))
+ path := pass.Fset.File(f.Body.Pos()).Name()
+ if !strings.HasSuffix(path, "_test.go") {
+ pass.Report(panicDiag(f.Body.Pos()))
+ }
}
}
}
@@ -144,16 +155,9 @@ func isPanicHandlerInstall(stmt ast.Stmt) bool {
return i.Name == "log" && s.Sel.Name == "PanicHandler"
}
-// golang-lint required plugin api
-type analyzerPlugin struct{}
-
-// This must be implemented
-func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
- return []*analysis.Analyzer{
+func main() {
+ multichecker.Main(
PanicAnalyzer,
PanicIndirectAnalyzer,
- }
+ )
}
-
-// This must be defined and named 'AnalyzerPlugin'
-var AnalyzerPlugin analyzerPlugin