chimon2000/good_first_issue
Duplicate Code: Identical EmptyCard and InitialCard Widgets
Open
#37 opened on Feb 16, 2026
enhancementgood first issuerefactoring
Repository metrics
- Stars
- (16 stars)
- PR merge metrics
- (PR metrics pending)
Description
Analysis of commit eaf30eabe62f9b178466629c6d3a4c4390e17311
Summary
Two widget classes (EmptyCard and InitialCard) have identical implementations with only different class names. Both render empty centered columns with no content, representing code duplication that reduces maintainability.
Duplication Details
Pattern: Identical Widget Structure
- Severity: High
- Occurrences: 2 instances
- Locations:
lib/ui/widgets/empty_card.dart(lines 1-17)lib/ui/widgets/initial_card.dart(lines 1-17)
- Code Sample:
class EmptyCard extends StatelessWidget { const EmptyCard({ Key? key, }) : super(key: key); `@override` Widget build(BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: const [], ), ); } }
Impact Analysis
- Maintainability: Any changes to the widget structure must be duplicated across both files, increasing the risk of inconsistent behavior
- Bug Risk: If one widget is updated but the other isn't, it creates inconsistent UI states that could confuse users
- Code Bloat: Unnecessary duplication adds to codebase size and complexity
Refactoring Recommendations
-
Consolidate into Single Widget
- Create a single
EmptyStateCardwidget that replaces both - Update all references in
lib/ui/pages/home.dartto use the consolidated widget - Estimated effort: 1-2 hours
- Benefits: Single source of truth, easier to extend with custom messages or icons in the future
- Create a single
-
Alternative: Add Distinguishing Content
- If these widgets are meant to represent different states (empty results vs initial loading), add distinctive content (icons, messages) to justify their separation
- Benefits: Makes the UI more informative to users
Implementation Checklist
- Review duplication findings
- Prioritize refactoring tasks
- Create refactoring plan
- Implement changes
- Update tests
- Verify no functionality broken
Analysis Metadata
- Analyzed Files: 27
- Detection Method: Semantic code analysis (manual review)
- Commit: eaf30eabe62f9b178466629c6d3a4c4390e17311
- Analysis Date: 2026-02-16
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.