analysis/docs/contribution-guide/endpoint-card.md
The endpoint card is a structured analysis template for evaluating existing Analysis API endpoints. It helps contributors systematically assess API endpoints from multiple perspectives: clarity, usage patterns, design quality, and potential improvements. Use this card when analyzing an endpoint for refactoring, enhancement, or deprecation to ensure thorough evaluation of its current state and identify areas for improvement.
Provide a clear, concise description of what the endpoint does in 1–2 sentences. Focus on the primary functionality and expected behavior. If describing the endpoint's purpose is challenging, or it requires multiple sentences, this may indicate the method has too many responsibilities and could benefit from decomposition.
Example:
Checks if a symbol is visible in the given context.
Evaluate how easily developers can understand the endpoint's purpose and behavior without diving into implementation details.
Examples:
For
javaGetterName, there is no KDoc. The extension always returns some name, even if the property doesn’t have a getter. It’s unclear how the method works forexpectdeclarations or for non-JVM platforms. It’s unclear whether it checks the@JvmNameannotation or handles bytecode mangling for inline classes.
The function name
analyseImports()is too generic. It does not suggest that the method is part of the import optimizer implementation and is not designed for general use.
Identify where and how frequently the endpoint is used across different contexts. The scale of usage is more important than exact counts and helps prioritize design work.
Usage contexts to check:
Questions to consider:
Look for repetitive code patterns that appear consistently across different usages of the endpoint. Common patterns may indicate missing convenience methods, unclear API design, or opportunities for improvement.
Questions to consider:
Example:
Before all calls of
isPublicApi, there is ais KtSymbolWithVisibilitytype check that looks verbose.
Analyze whether the endpoint is being used as intended and whether there are better alternatives available.
Questions to evaluate:
Example:
resolveToCall()is often used to get the symbol for a successful call. Argument mapping and other facilities thatresolveToCall()provides are ignored. Possible reasons:
- It is not straightforward that
resolveToSymbol()can only be called on a reference (mainReference). People use what is available in > completion.resolveToCall()andresolveToSymbol()return different symbols in certain cases.
Assess the potential for misuse and the robustness of the endpoint's design.
Questions to consider:
Evaluate whether the endpoint strikes the right balance between generality and specificity.
Core vs. Convenience:
Generality and Extensibility:
Example:
containingJvmClassNamereturns the facade name for declarations in multi-file facades. While it might be helpful in understanding how the method can be called from Java, it does not answer the question of where the actual bytecode will be.
Use this template when creating documents or issues for endpoint analysis:
# Analysis API Endpoint Card: `EndpointName`
## Description
📝 Provide a clear, concise description of what the endpoint does in 1-2 sentences.
## Understandability
📝 Evaluate how easily developers can understand the endpoint's purpose and behavior.
**Related Issues found:**
📝 Provide a list of related issues.
## Usages
### Where is the endpoint used?
📝 Give approximate usage count and distribution across the library clients:
- [ ] Kotlin IntelliJ IDEA plugin
- [ ] External plugins (use the *Find External Usages* action)
- [ ] KSP
- [ ] Dokka
- [ ] Swift Export
- [ ] Other clients
### Are there common patterns?
📝 Describe any repetitive code patterns around endpoint usage.
### Are usages correct?
📝 Analyze whether the endpoint is being used as intended.
## Design
### Is it easy to abuse the endpoint?
📝 Assess potential for misuse and robustness.
### Is the endpoint generic enough?
📝 Evaluate the balance between generality and specificity.
## Recommendations
📝 Summarize key findings and recommended actions:
1.
2.
3.
## Severity
📝 Assess the endpoint severity based on its usage and impact:
- [ ] High (frequent usage, significant impact)
- [ ] Medium (moderate usage or impact)
- [ ] Low (infrequent usage, minimal impact)