Summary
An audit of all 11 init() functions in pkg/ non-test (Sergo Run 11) found 3 stub functions whose bodies contain nothing but a single log statement. Two of them advertise that they register scripts — but their accompanying comments admit the scripts were already removed. The third claims to initialize regex compilation, but the regex variables it references are compiled in package-level var (...) blocks that run independently. All three add startup cost and reader confusion for zero functional benefit.
Locations
1. pkg/workflow/js.go:14-16
func init() {
jsLog.Print("Script registration completed (embedded scripts removed)")
}
File-level comment at line 12-13 already says: "init registers scripts from js.go with the DefaultScriptRegistry. Note: Embedded scripts have been removed - scripts are now provided by actions/setup at runtime."
2. pkg/workflow/scripts.go:20-22
func init() {
scriptsLog.Print("Script registration completed (embedded scripts removed)")
}
File header (lines 5-6) already says: "This file previously managed embedded JavaScript scripts, but inline bundling has been removed. Scripts are now provided by the actions/setup action at runtime."
3. pkg/workflow/expression_patterns.go:92-94
func init() {
expressionPatternsLog.Print("Initializing expression pattern regex compilation")
}
The regex compilation is not performed here — it's done in the file-scope var (...) blocks that follow (lines 96+), which are evaluated independently of init(). The log message is misleading.
Impact
- Severity: Low — no correctness impact, but contributes to startup-time noise and confuses readers who expect
init() to do meaningful work.
- Affected files: 3 files in
pkg/workflow/.
- Risk of leaving: Future maintainers may copy this anti-pattern into new init() bodies; the misleading log message in
expression_patterns.go could send debuggers down a false trail when investigating slow startup.
Recommendation
Delete all 3 init() functions. The package-level logger variables (jsLog, scriptsLog, expressionPatternsLog) can remain — they're used elsewhere in their files. The log lines themselves provide zero diagnostic value: they fire on every CLI invocation and just confirm that Go ran init().
Before (js.go):
var jsLog = logger.New("workflow:js")
func init() {
jsLog.Print("Script registration completed (embedded scripts removed)")
}
After:
var jsLog = logger.New("workflow:js")
Validation
Audit Context
Acceptable init() patterns identified in Run 11 (kept):
pkg/linters/*/Analyzer.Flags.IntVar — flag registration into go/analysis
pkg/parser/virtual_fs_wasm.go — overrides readFileFunc under //go:build js || wasm
pkg/workflow/domains.go, permissions_toolset_data.go, github_tool_to_toolset.go — unmarshal embedded JSON into runtime maps
pkg/workflow/runtime_definitions.go, safe_update_enforcement.go — derive lookup maps from knownRuntimes
References:
Generated by Sergo — Run 11
Generated by 🤖 Sergo - Serena Go Expert · ● 15.6M · ◷
Summary
An audit of all 11
init()functions inpkg/non-test (Sergo Run 11) found 3 stub functions whose bodies contain nothing but a single log statement. Two of them advertise that they register scripts — but their accompanying comments admit the scripts were already removed. The third claims to initialize regex compilation, but the regex variables it references are compiled in package-levelvar (...)blocks that run independently. All three add startup cost and reader confusion for zero functional benefit.Locations
1.
pkg/workflow/js.go:14-16File-level comment at line 12-13 already says: "init registers scripts from js.go with the DefaultScriptRegistry. Note: Embedded scripts have been removed - scripts are now provided by actions/setup at runtime."
2.
pkg/workflow/scripts.go:20-22File header (lines 5-6) already says: "This file previously managed embedded JavaScript scripts, but inline bundling has been removed. Scripts are now provided by the actions/setup action at runtime."
3.
pkg/workflow/expression_patterns.go:92-94The regex compilation is not performed here — it's done in the file-scope
var (...)blocks that follow (lines 96+), which are evaluated independently ofinit(). The log message is misleading.Impact
init()to do meaningful work.pkg/workflow/.expression_patterns.gocould send debuggers down a false trail when investigating slow startup.Recommendation
Delete all 3
init()functions. The package-level logger variables (jsLog,scriptsLog,expressionPatternsLog) can remain — they're used elsewhere in their files. The log lines themselves provide zero diagnostic value: they fire on every CLI invocation and just confirm that Go raninit().Before (js.go):
After:
Validation
go vet ./...andgo test ./...after deletion — no behavioral change expected.jsLog,scriptsLog,expressionPatternsLogto confirm they're still used elsewhere (they are; safe to keep the var declarations).init()in the package depends on ordering relative to these three (none do — they have no observable side effects).Audit Context
Acceptable init() patterns identified in Run 11 (kept):
pkg/linters/*/Analyzer.Flags.IntVar— flag registration into go/analysispkg/parser/virtual_fs_wasm.go— overridesreadFileFuncunder//go:build js || wasmpkg/workflow/domains.go,permissions_toolset_data.go,github_tool_to_toolset.go— unmarshal embedded JSON into runtime mapspkg/workflow/runtime_definitions.go,safe_update_enforcement.go— derive lookup maps fromknownRuntimesReferences:
Generated by Sergo — Run 11