Repository navigation
Description
Context
Follow-up to #45. Gaze v1.4.2 still produces "multiple target functions detected" warnings during quality analysis with no guidance on how to resolve them. This remains one of the most confusing aspects of using gaze quality analysis.
Problem
During CI quality analysis of a real project (get-out), gaze produces warnings like:
warning: TestClientFromStore_ValidToken_ContractAssertions: multiple target
functions detected: ClientFromStore, LoadTokenFromStore, testFileStore,
writeCredentials, writeToken
warning: TestLoadConversations_ContractAssertions: multiple target functions
detected: (*ConversationsConfig).FilterByExport, (*ConversationsConfig).GetByID,
LoadConversations, isValidConversationType, isValidExportMode, validateConversationConfig
These warnings mean gaze cannot determine which function the test targets, so contract coverage is diluted or unmapped. The developer sees the warning but has no idea:
- Why setup helpers like
testFileStoreandwriteTokenare detected as targets - How to restructure tests to have unambiguous targets
- Whether
t.Helper()affects target detection - Whether naming conventions matter (e.g.,
TestFuncName_Scenario)
Real-world impact
In the get-out project, 30+ tests produced this warning. The total quality analysis had 207 test reports but many had diluted contract coverage because of ambiguous target resolution. This directly contributed to the low contract coverage score (11% in CI) despite tests having explicit assertions on every return value.
What would help
Option A: Documentation
A section in gaze docs explaining:
- How gaze determines which function a test targets
- What causes a test to have multiple detected targets
- Best practices for test structure that gaze can analyze cleanly
Option B: Report guidance
When warnings exceed a threshold, include a summary in the report:
Quality Analysis Warnings:
- 30 tests have ambiguous targets (multiple functions detected)
- This reduces contract coverage accuracy
- Tip: Extract setup code into helper functions marked with t.Helper(),
and name tests as TestTargetFunction_Scenario
Option C: Annotation support
A comment convention that lets developers explicitly declare the target:
func TestClientFromStore_ValidToken(t *testing.T) {
// gaze:target=ClientFromStore
...
}
Any of these would significantly reduce confusion.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
- StatusShow more project fieldsNo status
Activity
jflowers commentedon Mar 16, 2026
Triage
Priority: Medium
Milestone: v1.5.0
Effort: Small (warning hint) to Medium (annotation support)
What already exists (v1.4.2):
t.Helper(), naming conventions)t.Runsub-tests,--targetflag)What's missing:
The warning message itself doesn't reference the documentation. A user seeing
warning: TestFoo: multiple target functions detected: A, B, Chas no idea where to look for help.Recommended fixes (two phases):
Phase 1 (Low effort — do now):
Update the warning message in
internal/quality/pairing.go:198to include a hint:"warning: %s: multiple target functions detected: %s. See README 'How Target Inference Works' for guidance."Phase 2 (Medium effort — future):
Add
// gaze:target=FuncNameannotation support. When present in a test function, gaze uses the declared target instead of SSA call graph inference. This gives users explicit control without restructuring their tests.Related: #45 (target inference docs — closed), #6 (AST-to-SSA bridge — partially addressed)
fix: add guidance reference to multiple target functions warning (issue
fix: add guidance reference to multiple target functions warning (issue