Polish context output and auto-discover dep scopes - #5
Conversation
- Skip empty root project row in projects table - Overview counts symbols from included builds - Proper singular/plural: "1 project", "2 dependents" - Rename "Dashboard" column to "Context" - Deduplicate findings across source sets - Auto-discover all dependency configurations instead of hardcoded whitelist - New excludeDepScopes extension property (defaults exclude Kotlin internals)
📝 WalkthroughWalkthroughAdds a configurable dependency-scope exclusion (DSL + task input), wires it into task configuration, propagates it into dependency extraction to skip scopes, and refines report rendering (pluralization, dedupe, and renaming a table column). Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(220,235,255,0.5)
participant Ext as SettingsExtension
participant Task as ContextTask
participant SE as SymbolExtractor
participant PR as Project/Build
end
Ext->>Task: set excludeDepScopes.convention(...)
Task->>SE: request extractDependenciesFromProject(proj, excludeScopes)
SE->>PR: iterate configurations / build files
SE->>PR: skip configs/calls in excludeScopes
PR-->>SE: return filtered dependency entries
SE-->>Task: deliver deduplicated dependencies
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt`:
- Around line 246-254: The PSI parser currently uses a hardcoded allowlist
PSI_DEP_SCOPES in extractDependenciesFromBuildFile which misses custom
configurations; change it to the same exclude-based model used elsewhere by
removing PSI_DEP_SCOPES and replacing the scopes parameter with an exclude set
(reuse the existing excludeDepScopes symbol) and alter the parsing logic in
extractDependenciesFromBuildFile to accept any declared scope except those
present in excludeDepScopes (i.e., filter out declarations whose configuration
name is in excludeDepScopes) — also update the similar check referenced around
the other occurrence (line ~266) so both PSI and Gradle-backed paths use the
excludeDepScopes-driven behavior.
In `@src/main/kotlin/zone/clanker/gradle/srcx/Srcx.kt`:
- Around line 155-160: projectDeps is being computed from
extension.excludeDepScopes instead of the task's configured property, so updates
to task.excludeDepScopes (e.g. via tasks.named{...}.excludeDepScopes.set(...))
aren't reflected; change the provider that sets task.projectDeps to read the
task-level value (use task.excludeDepScopes.get() or
task.excludeDepScopes.asProvider()) when calling
SymbolExtractor.extractDependenciesFromProject so the computed dependencies stay
in sync with the task property (refer to task.excludeDepScopes, projectDeps,
extension.excludeDepScopes, and SymbolExtractor.extractDependenciesFromProject).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 706c2f7e-44e3-4208-a3fe-884cddaa59c2
📒 Files selected for processing (8)
src/main/kotlin/zone/clanker/gradle/srcx/Srcx.ktsrc/main/kotlin/zone/clanker/gradle/srcx/report/DashboardRenderer.ktsrc/main/kotlin/zone/clanker/gradle/srcx/report/IncludedBuildRenderer.ktsrc/main/kotlin/zone/clanker/gradle/srcx/report/ProjectReportRenderer.ktsrc/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.ktsrc/main/kotlin/zone/clanker/gradle/srcx/task/ContextTask.ktsrc/test/kotlin/zone/clanker/gradle/srcx/SrcxIncludedBuildPluginTest.ktsrc/test/kotlin/zone/clanker/gradle/srcx/report/DashboardIncludedBuildTest.kt
…y wiring - PSI build file parser now uses exclude-based model matching Gradle API path - PSI_SKIP_CALLS filters known non-dependency call expressions - projectDeps wired from task.excludeDepScopes (not extension directly)
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt`:
- Around line 274-279: The current descendant scan in SymbolExtractor.kt
collects every KtCallExpression which over-matches nested/helper calls (e.g.,
platform("g:a:v") inside implementation) — restrict the filter to only top-level
call sites by adding a parent check in the chain: when filtering the
KtCallExpression (the call variable in the .filter { ... } block), exclude calls
whose parent is another KtCallExpression or a KtValueArgument (or other wrapper
nodes that indicate the call is nested) so only declaration-level calls (e.g.,
implementation { ... } or direct configuration calls) are emitted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 745e80f3-0a89-4772-8dd3-5afdac9f40ef
📒 Files selected for processing (2)
src/main/kotlin/zone/clanker/gradle/srcx/Srcx.ktsrc/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt
| ktFile | ||
| .collectDescendantsOfType<KtCallExpression>() | ||
| .filter { call -> call.calleeExpression?.text in DEP_SCOPES } | ||
| .mapNotNull { call -> | ||
| .filter { call -> | ||
| val name = call.calleeExpression?.text ?: return@filter false | ||
| name !in excludeScopes && name !in PSI_SKIP_CALLS | ||
| }.mapNotNull { call -> |
There was a problem hiding this comment.
PSI dependency scan can over-match nested/helper calls.
Because Line 275 scans all call expressions, nested calls like platform("g:a:v") can be emitted as scope platform instead of the declaration scope (implementation), which can skew the report.
Suggested fix
ktFile
.collectDescendantsOfType<KtCallExpression>()
.filter { call ->
val name = call.calleeExpression?.text ?: return@filter false
- name !in excludeScopes && name !in PSI_SKIP_CALLS
+ call.isTopLevelDependencyDeclaration() &&
+ name !in excludeScopes &&
+ name !in PSI_SKIP_CALLS
}.mapNotNull { call ->
@@
}
}
}
+
+ private fun KtCallExpression.isTopLevelDependencyDeclaration(): Boolean {
+ val nearestParentCall =
+ generateSequence(parent) { it.parent }
+ .filterIsInstance<KtCallExpression>()
+ .firstOrNull()
+ ?: return false
+ return nearestParentCall.calleeExpression?.text == "dependencies"
+ }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt` around
lines 274 - 279, The current descendant scan in SymbolExtractor.kt collects
every KtCallExpression which over-matches nested/helper calls (e.g.,
platform("g:a:v") inside implementation) — restrict the filter to only top-level
call sites by adding a parent check in the chain: when filtering the
KtCallExpression (the call variable in the .filter { ... } block), exclude calls
whose parent is another KtCallExpression or a KtValueArgument (or other wrapper
nodes that indicate the call is nested) so only declaration-level calls (e.g.,
implementation { ... } or direct configuration calls) are emitted.
* Polish context output and auto-discover dependency scopes - Skip empty root project row in projects table - Overview counts symbols from included builds - Proper singular/plural: "1 project", "2 dependents" - Rename "Dashboard" column to "Context" - Deduplicate findings across source sets - Auto-discover all dependency configurations instead of hardcoded whitelist - New excludeDepScopes extension property (defaults exclude Kotlin internals) * Address CodeRabbit: exclude-based PSI dep parsing, task-level property wiring - PSI build file parser now uses exclude-based model matching Gradle API path - PSI_SKIP_CALLS filters known non-dependency call expressions - projectDeps wired from task.excludeDepScopes (not extension directly)
Summary
excludeDepScopesextension property with sensible defaultsTest plan
Summary by CodeRabbit
New Features
Bug Fixes
Improvements
Tests