[docs-utils] 4️⃣ Add missingReturns validation to API stats#250816
Merged
clintandrewhall merged 3 commits intoelastic:mainfrom Feb 23, 2026
Merged
[docs-utils] 4️⃣ Add missingReturns validation to API stats#250816clintandrewhall merged 3 commits intoelastic:mainfrom
missingReturns validation to API stats#250816clintandrewhall merged 3 commits intoelastic:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds validation for missing @returns JSDoc documentation in function declarations. The new missingReturns stat tracks functions that return non-void values but lack return documentation, helping maintain API documentation quality across Kibana plugins.
Changes:
- Added
missingReturnsfield toApiStatsinterface for tracking functions without return documentation - Implemented detection logic to identify function-like declarations and exclude void returns from validation
- Updated test infrastructure and fixture scripts to support the new validation category
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/kbn-docs-utils/src/types.ts | Added missingReturns field to ApiStats and introduced IssuesByPlugin interface |
| packages/kbn-docs-utils/src/stats.ts | Implemented function detection, void return checking, and return documentation tracking logic |
| packages/kbn-docs-utils/src/stats.test.ts | Updated tests to use createEmptyIssues helper and new function signature |
| packages/kbn-docs-utils/src/integration_tests/snapshots/* | Updated snapshot dates and added missingReturns data to test fixtures |
| packages/kbn-docs-utils/src/integration_tests/api_doc_suite.test.ts | Updated to use new IssuesByPlugin parameter structure |
| packages/kbn-docs-utils/src/cli/tasks/collect_stats.ts | Updated function call to use IssuesByPlugin object parameter |
| packages/kbn-docs-utils/src/cli/tasks/collect_stats.test.ts | Added missingReturns to mock stats |
| packages/kbn-docs-utils/src/test_helpers/mocks.ts | Added missingReturns initialization to mock helper functions |
| packages/kbn-docs-utils/src/README.md | Reformatted documentation with improved structure and clarity |
| packages/kbn-docs-utils/scripts/update_fixture_comments.js | Added missingReturns to categories array |
37097ad to
2ab468b
Compare
13 tasks
missingReturns validation to API statsmissingReturns validation to API stats
2ab468b to
5c0467d
Compare
Contributor
|
Pinging @elastic/kibana-operations (Team:Operations) |
8ae03a4 to
f96fb99
Compare
Track functions missing `@returns` documentation, excluding `void` and `Promise<void>` return types.
f96fb99 to
076b882
Compare
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
bhapas
pushed a commit
to bhapas/kibana
that referenced
this pull request
Feb 25, 2026
qn895
pushed a commit
to qn895/kibana
that referenced
this pull request
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
missingReturnsvalidation to thekbn-docs-utilsAPI stats collection. This tracks functions that are missing@returnsJSDoc documentation, helping improve API documentation quality across the codebase.Note
This PR is a subset of #247688 for ease of review.
This PR was written with Cursor and
claude-4.5-opus-high.Important
This PR relies on #250810 and includes it as its base commit. This PR will remain draft until that PR is merged and this branch is rebased.
Before / After Example
Given these TypeScript functions:
Before this PR:
No validation existed for missing
@returnsdocumentation. Functions without return documentation passed silently:{ "counts": { "missingComments": 0 } }After this PR:
Functions missing
@returnsare now flagged separately:{ "counts": { "missingComments": 0, "missingReturns": 1 // ✅ getUser flagged (non-void, no @returns) }, "missingReturns": [ { "id": "def-public.getUser", "label": "getUser", "type": "Function", "lineNumber": 2 } // logMessage NOT flagged (returns void - no @returns needed) // createSearchService NOT flagged (has @returns comment) ] }Smart Void Exclusion
Functions returning
void-like types are automatically excluded since they don't need@returnsdocumentation:string@returnsPromise<User>@returnsvoidundefinedPromise<void>Promise<undefined>Changes
missingReturnsstat - Added toApiStatsinterface to track functions without return documentation.TypeKind.FunctionKindor arrow syntax (=>) in signatures.void,undefined,Promise<void>,Promise<undefined>) since these don't require@returnsdocumentation.update_fixture_comments.jsto include the newmissingReturnscategory.Impact
@returnsdocumentation--check commentsflag incheck_package_docs