-
Notifications
You must be signed in to change notification settings - Fork 265
Automatically fix broken links #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for docs-optimism ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
📝 WalkthroughWalkthroughThe changes update the project’s maintenance scripts and add functionality to handle broken links. In the Sequence Diagram(s)sequenceDiagram
participant U as User/Developer
participant PM as Package Manager ("pnpm fix")
participant FS as File System (Documentation Files)
participant UT as fix-broken-links Utility
participant RG as Report Generator
U->>PM: Run "pnpm fix"
PM->>UT: Execute "pnpm fix-links" script
UT->>FS: Scan documentation files for links
FS-->>UT: Return list of files
UT->>UT: Extract links & identify broken links
UT->>UT: Attempt auto-fix for each broken link
UT->>RG: Generate audit report
RG-->>UT: Return report summary
UT->>PM: Return fixed link status and report
PM->>U: Display aggregated fix report
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 (5)
utils/fix-broken-links.ts (5)
58-78
: Consider adding a toggle for backups or integrating revision history.
Even thoughbackupFiles
is disabled by default, overwriting original files may risk accidental data loss during fixes. You may want to allow a simple rollback mechanism or track changes so users can revert if needed.
80-106
: Potential concurrency optimization for large repositories.
TherunLinkFixer
function processes files sequentially, which may become slow if the codebase is large. Introducing concurrency or a pool-based approach to reading and writing files could improve performance. Ensure to handle potential race conditions carefully.
130-184
: Enhance error reporting for broken links.
Currently, the script reports broken links but does not categorize the type of issue (e.g., file not found, link not recognized). Including more specific error messages — for instance, “File not found within docs directory” — could help users quickly diagnose problems.
186-279
: Validate cross-file references or external imports conditionally.
TheextractLinks
function might encounter references to local or external resources. If intended to skip verifying external resources, ensure to highlight them differently or store them for a separate check. This can improve the clarity of the link-auditing process.
339-507
: Consider user feedback loop and test coverage.
ThefixBrokenLinks
function automatically fixes broken links, which is great. However:
• It would be beneficial to gather user feedback in real-world scenarios to ensure the logic matches user expectations.
• Adding test coverage (unit tests or integration tests) would ensure the reliability of these fixes and help detect regressions quickly.Would you like me to create an initial test suite for this function or open a new GitHub issue tracking the coverage improvements?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
package.json
(2 hunks)utils/fix-broken-links.ts
(1 hunks)words.txt
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
words.txt
[duplication] ~118-~118: Možný preklep: zopakovali ste slovo
Context: ...therbase Ethernity Ethernow ethpandaops ETHSTATS ethstats EVMTIMEOUT evmtimeout executability exf...
(WORD_REPEAT_RULE)
🔇 Additional comments (3)
words.txt (1)
118-118
: No issues found regarding the newly added word.This looks like a legitimate addition to the known word list. The static analysis hint likely flagged a false positive “word repetition.” There is no apparent duplication in this context.
🧰 Tools
🪛 LanguageTool
[duplication] ~118-~118: Možný preklep: zopakovali ste slovo
Context: ...therbase Ethernity Ethernow ethpandaops ETHSTATS ethstats EVMTIMEOUT evmtimeout executability exf...(WORD_REPEAT_RULE)
utils/fix-broken-links.ts (1)
631-633
: Exit code usage is correct but verify CI integration.
The script usesprocess.exit(1)
when broken links remain. Ensure this behavior aligns with your CI/CD pipeline requirements (e.g., failing a build if any broken links are found).package.json (1)
8-9
: Script addition appears valid and well-integrated.
Appendingpnpm fix-links
to the existing"fix"
script, alongside the new"fix-links"
script definition, properly incorporates the link-fixing utility into your workflow without disrupting other tasks.Also applies to: 17-17
Description
Implement Broken Links Auto-Fixer
This PR adds an automatic broken link fixer that extends our existing link checker to not only detect broken internal links but also repair them using intelligent path matching.
Features
Automatic Link Repair: Fixes broken internal links without manual intervention
Smart Path Detection: Uses multiple strategies to find the correct path:
Comprehensive Reporting: Shows detailed statistics about fixed vs unfixable links
Non-destructive Operation: Carefully modifies files without side effects
Tests
Additional context
Metadata