Skip to content

Conversation

@skydoves
Copy link
Owner

@skydoves skydoves commented Nov 7, 2025

Handle StabilityInferred annotated composables.

Summary by CodeRabbit

  • New Features

    • Added support for reading @StabilityInferred annotation parameters for cross-module stability detection.
  • Improvements

    • Enhanced stability analysis for classes across modules with improved annotation detection and handling.
    • External module classes are now properly classified based on stability annotations and parameter values with defensive error handling.

@skydoves skydoves self-assigned this Nov 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Walkthrough

The changes add support for reading @StabilityInferred annotation parameters to enhance cross-module stability detection. The implementation parses the parameters argument from the androidx.compose.runtime.internal.StabilityInferred annotation on class symbols, enabling proper detection of class stability across module boundaries.

Changes

Cohort / File(s) Summary
Documentation
compose-stability-analyzer-idea/CHANGELOG.md
Added changelog entries documenting support for @StabilityInferred annotation parameter reading and improved cross-module stability detection (Issue #18).
Annotation Parsing
compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/KtStabilityInferencer.kt
Implemented parsing logic for @StabilityInferred(parameters=...) on KaClassSymbol. Replaces placeholder with logic to locate annotation, extract parameters argument, and parse integer value. Returns parsed value or null on failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Focus areas:
    • Verify annotation detection logic correctly locates androidx.compose.runtime.internal.StabilityInferred
    • Confirm parameter extraction and integer parsing handles edge cases and invalid input defensively
    • Ensure return semantics (null vs. integer value) align with caller expectations
    • Validate that KaSession context is appropriately utilized

Poem

🐰 Across module bounds we leap with care,
@StabilityInferred—a parameter fair!
Parse and detect with logical might,
Cross-module stability, burning bright! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is minimal and lacks the required structure from the template (Goal, Implementation details, Examples, Preparation steps). Expand the description to include: the goal/motivation (referencing Issue #18), implementation details explaining @StabilityInferred parameter parsing, code examples, and confirmation that spotlessApply and apiDump were run.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Handle StabilityInferred annotated composables' clearly summarizes the main change - adding support for @StabilityInferred annotation handling for cross-module stability detection.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/StabilityInferred

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
compose-stability-analyzer-idea/CHANGELOG.md (1)

10-10: Consolidate duplicate changelog entries for @StabilityInferred support.

Lines 10 and 17–18 document the same feature—support for reading @StabilityInferred annotation parameters. This duplication may confuse readers. Additionally, lines 17–18 describe improvements and behavior changes rather than fixes, so they may belong in an "Improved" section if kept separate.

Recommendation: Consolidate into a single, comprehensive entry that covers both the capability (what was added) and the behavior (what it enables). Consider whether it belongs in "Added" or "Improved" based on the nature of the change.

Example consolidation:

 ### Added
 - New setting: "Show in test source sets" for gutter icons (Issue #21)
 - Gutter icons are now hidden in test directories by default (can be enabled in settings)
-- Support for reading @StabilityInferred annotation parameters for cross-module stability detection (Issue #18)
+- Support for reading @StabilityInferred annotation parameters for cross-module stability detection (Issue #18)
+  - Classes from other modules now correctly marked as UNSTABLE unless annotated with @Stable/@Immutable or @StabilityInferred(parameters=0)

 ### Fixed
 - Fixed typealias detection for Composable function types (Issue #16)
 - Typealiases like `typealias SettingsButtons = @Composable (PlayerUiState) -> Unit` now correctly expand to their underlying function types before stability analysis
 - Fixed ImmutableList/ImmutableSet/ImmutableMap showing as unstable in test code (Issue #21)
 - Added fallback type resolution by simple name for immutable collections when FQN resolution fails in test source sets
-- Improved cross-module stability detection by reading @StabilityInferred(parameters) annotation (Issue #18)
-- Classes from other modules now correctly marked as UNSTABLE unless annotated with @Stable/@Immutable or @StabilityInferred(parameters=0)

Also applies to: 17-18

compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/KtStabilityInferencer.kt (1)

600-639: Well-implemented annotation parsing with defensive error handling.

The implementation correctly reads the @StabilityInferred annotation and extracts the parameters value. The logic properly handles edge cases (missing annotation, missing argument, wrong type) by returning null, which is the correct fallback behavior.

Optional: Address the detekt warning about the swallowed exception.

The try-catch at lines 624-638 intentionally swallows exceptions for defensive behavior, which is appropriate here. However, consider adding a brief comment explaining why exceptions are caught and ignored, to prevent future developers from "fixing" this:

   // Extract the Int value from the constant expression
   return try {
+    // Defensive: return null if parsing fails due to API changes or unexpected format
     when (val expression = parametersArgument?.expression) {

This will clarify that the exception swallowing is intentional rather than an oversight.

As per static analysis hints.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 309b3d1 and 32eba91.

📒 Files selected for processing (2)
  • compose-stability-analyzer-idea/CHANGELOG.md (1 hunks)
  • compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/KtStabilityInferencer.kt (1 hunks)
🧰 Additional context used
🪛 detekt (1.23.8)
compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/KtStabilityInferencer.kt

[warning] 636-636: The caught exception is swallowed. The original exception could be lost.

(detekt.exceptions.SwallowedException)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Compiler Tests (FIR/IR Dumps)
  • GitHub Check: Runtime Module Tests
  • GitHub Check: Test IntelliJ Plugin
  • GitHub Check: Build IntelliJ Plugin
  • GitHub Check: Build and Tests
  • GitHub Check: API check
  • GitHub Check: Spotless check

@skydoves skydoves merged commit 65b595c into main Nov 7, 2025
11 checks passed
@skydoves skydoves deleted the feature/StabilityInferred branch November 7, 2025 23:40
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.

2 participants