-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Summary
Duplicate URL launching logic exists in both AboutPage and LinkService with inconsistent implementations. The AboutPage directly uses url_launcher APIs while LinkService wraps them, creating maintenance burden and inconsistency.
Duplication Details
Pattern: URL Launching with Capability Check
-
Severity: Medium
-
Occurrences: 2 instances
-
Locations:
lib/ui/pages/about.dart(lines 77-80)lib/services/link.dart(lines 7-11)
-
Code Samples:
AboutPage implementation:
if (await canLaunchUrl(Uri.parse(url!))) {
await launchUrl(Uri.parse(url));
} else {
throw 'Could not launch $url';
}LinkService implementation:
if (await canLaunchUrlString(link)) {
await launchUrlString(link);
} else {
throw 'Could not launch $link';
}Impact Analysis
- Maintainability: Updates to URL launching behavior must be made in multiple places
- Bug Risk: Different implementations (Uri.parse vs string) can lead to inconsistent behavior
- Code Bloat: Unnecessary duplication of error handling logic
- Inconsistency: AboutPage bypasses the LinkService abstraction that other pages use
Refactoring Recommendations
-
Consolidate URL launching through LinkService
- Update AboutPage to use
ref.read(linkServiceProvider).launchLink(url)instead of direct url_launcher calls - Estimated effort: 15 minutes
- Benefits: Single source of truth for URL launching, consistent error handling, easier testing
- Update AboutPage to use
-
Consider adding a launchUri method to LinkService
- Add method that accepts Uri objects if needed
- Benefits: Flexibility while maintaining centralized logic
Implementation Checklist
- Review duplication findings
- Update AboutPage to use LinkService for URL launching (lines 77-80)
- Remove direct url_launcher imports from AboutPage
- Update tests to verify LinkService integration
- Verify all URL launching works correctly
Analysis Metadata
- Analyzed Files: 33
- Detection Method: Pattern matching and semantic analysis
- Commit: eaf30ea
- Analysis Date: 2026-02-24
AI generated by Duplicate Code Detector
To add this workflow in your repository, run
gh aw add github/gh-aw/.github/workflows/duplicate-code-detector.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4. See usage guide.
Reactions are currently unavailable