Skip to content

Polish context output and auto-discover dep scopes - #5

Merged
ClankerGuru merged 2 commits into
mainfrom
polish-context-output
Apr 9, 2026
Merged

Polish context output and auto-discover dep scopes#5
ClankerGuru merged 2 commits into
mainfrom
polish-context-output

Conversation

@ClankerGuru

@ClankerGuru ClankerGuru commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Skip empty root project row in projects table
  • Overview counts symbols from all included builds
  • Proper singular/plural throughout
  • Rename "Dashboard" column to "Context"
  • Deduplicate findings across source sets
  • Auto-discover all dependency configurations instead of hardcoded whitelist
  • New excludeDepScopes extension property with sensible defaults

Test plan

  • Run on clanker-demo composite build
  • Verify no duplicate warnings in turbine output
  • Verify root row with 0 symbols is omitted
  • Verify symbol count includes included builds

Summary by CodeRabbit

  • New Features

    • Add configuration to exclude specific dependency scopes from scanning (project-level setting and task input).
  • Bug Fixes

    • De-duplicate problem reports to avoid repeated warnings/info.
  • Improvements

    • Include included-build symbols in overview totals.
    • Better pluralization and singular/plural dependent labels; skip empty project rows.
    • Rename report column header from "Dashboard" to "Context".
  • Tests

    • Updated expectations for the changed header label.

- 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)
@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Configuration & Task
src/main/kotlin/zone/clanker/gradle/srcx/Srcx.kt, src/main/kotlin/zone/clanker/gradle/srcx/task/ContextTask.kt
Introduce DEFAULT_EXCLUDED_DEP_SCOPES and SettingsExtension.excludeDepScopes: SetProperty<String>; add ContextTask.excludeDepScopes: SetProperty<String> and wire extension -> task convention.
Dependency Extraction
src/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt
Parameterized extraction APIs with excludeScopes (defaults to new constant); project/build-file extraction now skips configured scopes, assigns config.name as scope, and deduplicates dependency entries.
Report Rendering
src/main/kotlin/zone/clanker/gradle/srcx/report/DashboardRenderer.kt, src/main/kotlin/zone/clanker/gradle/srcx/report/IncludedBuildRenderer.kt, src/main/kotlin/zone/clanker/gradle/srcx/report/ProjectReportRenderer.kt
Pluralization for dependent(s), deduplicate problem/findings by message, skip empty project rows, and rename final column header from “Dashboard” to “Context”.
Tests
src/test/kotlin/zone/clanker/gradle/srcx/SrcxIncludedBuildPluginTest.kt, src/test/kotlin/zone/clanker/gradle/srcx/report/DashboardIncludedBuildTest.kt
Update assertions to expect Context as the final table column header instead of Dashboard.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I nibble scopes that ought to skip,
Excluding noise with a happy flip,
Tasks take the list, extractors obey,
Reports tidy up what hops our way—
A carrot-sized change, hip-hip-hooray! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Polish context output and auto-discover dep scopes' clearly and concisely summarizes the two main changes: UI/output improvements and the shift to an exclude-based dependency scope discovery mechanism.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch polish-context-output

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2a043 and 788aa39.

📒 Files selected for processing (8)
  • src/main/kotlin/zone/clanker/gradle/srcx/Srcx.kt
  • src/main/kotlin/zone/clanker/gradle/srcx/report/DashboardRenderer.kt
  • src/main/kotlin/zone/clanker/gradle/srcx/report/IncludedBuildRenderer.kt
  • src/main/kotlin/zone/clanker/gradle/srcx/report/ProjectReportRenderer.kt
  • src/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt
  • src/main/kotlin/zone/clanker/gradle/srcx/task/ContextTask.kt
  • src/test/kotlin/zone/clanker/gradle/srcx/SrcxIncludedBuildPluginTest.kt
  • src/test/kotlin/zone/clanker/gradle/srcx/report/DashboardIncludedBuildTest.kt

Comment thread src/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt Outdated
Comment thread src/main/kotlin/zone/clanker/gradle/srcx/Srcx.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)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 788aa39 and fd064bb.

📒 Files selected for processing (2)
  • src/main/kotlin/zone/clanker/gradle/srcx/Srcx.kt
  • src/main/kotlin/zone/clanker/gradle/srcx/scan/SymbolExtractor.kt

Comment on lines 274 to +279
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 ->

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

@ClankerGuru
ClankerGuru merged commit 9554234 into main Apr 9, 2026
2 checks passed
@ClankerGuru
ClankerGuru deleted the polish-context-output branch April 13, 2026 00:44
ClankerGuru added a commit that referenced this pull request Aug 11, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant