Address code review feedback: memory leak fix, SSL verification, test isolation #397
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.
What are you trying to accomplish?
Addresses code review feedback from PR #396 to improve code quality, security, and test reliability for the
AvatarWithFallbackcomponent.Key changes:
Memory leak prevention - Added
disconnectedCallback()to remove event listeners when component is removed from DOM. Prevents memory leaks in SPAs by storing bound function reference for proper cleanup.SSL certificate verification - Added
OpenSSL::SSL::VERIFY_PEERtourl_accessible?method to validate SSL certificates during HEAD requests, preventing MITM attacks.Test isolation - Added setup/teardown methods to preserve and restore
validate_urlsclass-level setting between tests, preventing test pollution.Better testing practices - Replaced
.any_instance.expectsanti-pattern with WebMock assertions (stub_request+assert_not_requested) to decouple tests from implementation details.Documentation grammar - Fixed "When nil, or broken URL it renders" → "When nil or a broken URL, it renders" in YARD docs and static files.
Integration
Risk Assessment
What approach did you choose and why?
TypeScript event listener cleanup follows standard web component lifecycle pattern. SSL verification uses OpenSSL's standard peer verification mode. Test isolation follows Ruby/Minitest best practices with setup/teardown hooks.
Anything you want to highlight for special attention from reviewers?
The
disconnectedCallbackstores the bound function reference rather than using an arrow function inline, which is necessary forremoveEventListenerto work correctly.Accessibility
Merge checklist
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.