The app and the command line each had their own copy of the language pack merge order. The locale code now has its own file. The package scan is split by what it checks, and a new test limits how long one function may get. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
936 B
Go
34 lines
936 B
Go
package archtest
|
|
|
|
import (
|
|
"go/ast"
|
|
"testing"
|
|
)
|
|
|
|
// maxFunctionLines keeps one function from collecting every step of a feature,
|
|
// where two changes to unrelated steps collide. Split it into named steps.
|
|
const maxFunctionLines = 300
|
|
|
|
func TestFunctionLength(t *testing.T) {
|
|
for _, src := range sources(t) {
|
|
for _, decl := range src.file.Decls {
|
|
fn, ok := decl.(*ast.FuncDecl)
|
|
if !ok {
|
|
continue
|
|
}
|
|
start, end := fileSet.Position(fn.Pos()).Line, fileSet.Position(fn.End()).Line
|
|
lines := end - start + 1
|
|
// Embedded scripts and templates are text, not steps.
|
|
ast.Inspect(fn, func(n ast.Node) bool {
|
|
if lit, ok := n.(*ast.BasicLit); ok {
|
|
lines -= fileSet.Position(lit.End()).Line - fileSet.Position(lit.Pos()).Line
|
|
}
|
|
return true
|
|
})
|
|
if lines > maxFunctionLines {
|
|
t.Errorf("%s:%d: %s has %d lines, the limit is %d", src.rel, start, fn.Name.Name, lines, maxFunctionLines)
|
|
}
|
|
}
|
|
}
|
|
}
|