Skip to content

Commit 0621b69

Browse files
SimplyLizclaude
andauthored
fix: make split recommendation based on module relationships, not symbol count (#122)
Previously, the change impact analysis recommended splitting PRs based solely on symbol count (>15). This was not useful - a cohesive feature adding many symbols to one module shouldn't be split. Now the split recommendation triggers only when: 1. Changes touch 2+ files (single file = cohesive by definition) 2. Impact affects 3+ distinct modules (suggesting broad changes) This ensures single-file PRs never get split recommendations, and multi-file PRs only get them when impact is truly widespread. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 60e46ca commit 0621b69

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

internal/query/impact.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,29 @@ func min(a, b int) int {
16801680
return b
16811681
}
16821682

1683+
// hasUnrelatedModuleChanges checks if changes span multiple unrelated modules.
1684+
// Returns true only when:
1685+
// 1. Changes touch 2+ files
1686+
// 2. Impact affects 3+ distinct modules (suggesting broad, disconnected changes)
1687+
func hasUnrelatedModuleChanges(changedSymbols []impact.ChangedSymbol, modules []ModuleImpact) bool {
1688+
// Count distinct files changed
1689+
changedFiles := make(map[string]bool)
1690+
for _, sym := range changedSymbols {
1691+
if sym.File != "" {
1692+
changedFiles[sym.File] = true
1693+
}
1694+
}
1695+
1696+
// Single file = cohesive by definition
1697+
if len(changedFiles) <= 1 {
1698+
return false
1699+
}
1700+
1701+
// Need 3+ affected modules to suggest unrelated changes
1702+
// (2 modules could easily be caller/callee)
1703+
return len(modules) >= 3
1704+
}
1705+
16831706
// generateRecommendations creates actionable recommendations based on impact analysis.
16841707
func (e *Engine) generateRecommendations(
16851708
summary *ChangeSummary,
@@ -1699,13 +1722,13 @@ func (e *Engine) generateRecommendations(
16991722
})
17001723
}
17011724

1702-
// Recommend splitting large changes
1703-
if summary.SymbolsChanged > 15 {
1725+
// Recommend splitting when changes span unrelated modules
1726+
if hasUnrelatedModuleChanges(changedSymbols, modules) {
17041727
recs = append(recs, Recommendation{
17051728
Type: "split",
17061729
Severity: "info",
1707-
Message: fmt.Sprintf("Large change with %d symbols modified. Consider splitting into smaller PRs.", summary.SymbolsChanged),
1708-
Action: "Break into smaller, focused changes",
1730+
Message: fmt.Sprintf("Changes affect %d distinct modules. Consider splitting into focused PRs.", len(modules)),
1731+
Action: "Group related changes into separate PRs",
17091732
})
17101733
}
17111734

0 commit comments

Comments
 (0)