94 lines
3.6 KiB
Plaintext
94 lines
3.6 KiB
Plaintext
# JavaScript Duplication Audit Report
|
|
|
|
**Generated:** 2026-02-26
|
|
**Scope:** static/js/**/*.js (13 files)
|
|
**Files Audited:** api.js, utils.js, auth.js, main.js, tabs.js, anime.js, series-search.js, downloads.js, watchlist/main.js, anime-details.js, recommendations.js, watchlist.js, watchlist-ui.js
|
|
|
|
---
|
|
|
|
## CRITICAL DUPLICATIONS (Potential Syntax Errors)
|
|
|
|
### 1. translateStatus() Function - DUPLICATED DEFINITION
|
|
- **File 1:** `static/js/utils.js:35` - Primary definition
|
|
- **File 2:** `static/js/anime-details.js:428` - Duplicate definition
|
|
|
|
**Impact:** HIGH - If both files are loaded, the second definition will overwrite the first, causing unpredictable behavior. The utils.js version is used by downloads.js and recommendations.js, while anime-details.js has its own localized version.
|
|
|
|
**Recommendation:** Remove duplicate in anime-details.js and ensure anime-details.js imports from utils.js
|
|
|
|
---
|
|
|
|
## MINOR DUPLICATIONS (Non-Breaking)
|
|
|
|
### 2. Redundant const Declarations in Same Function Scope (Different Functions)
|
|
|
|
#### auth.js - Duplicate variable declarations across functions
|
|
- `mainContent` declared at line 70 and line 76 (in different functions showMainContent/hideMainContent)
|
|
- `userInfo` declared at line 57 and line 82 (in showUserInfo/showLoginPrompt)
|
|
- `loginPrompt` declared at line 58 and line 83
|
|
- `mainTabs` declared at line 59 and line 84
|
|
|
|
**Impact:** LOW - These are in different function scopes, not causing syntax errors but creating redundant code
|
|
|
|
#### recommendations.js - Duplicate variable names in different functions
|
|
- `container` declared at lines 5, 54, 105 (in different functions)
|
|
- `section` declared at lines 6, 55 (in different functions)
|
|
|
|
**Impact:** LOW - Different function scopes
|
|
|
|
#### tabs.js - Duplicate container variable
|
|
- `container` declared at lines 115, 152, 160, 178, 186, 235, 252, 329
|
|
|
|
**Impact:** LOW - Different function scopes
|
|
|
|
#### anime.js - Duplicate variable names across functions
|
|
- `selectElement` declared at lines 156, 245, 253, 261, 307, 352
|
|
- `seasonSelectElement` declared at lines 156, 245
|
|
- `actionsDiv` declared at lines 287, 325
|
|
|
|
**Impact:** LOW - Different function scopes
|
|
|
|
---
|
|
|
|
## PATTERN OBSERVATIONS
|
|
|
|
### Utility Functions Shared Across Files
|
|
The following functions are defined once but used across multiple files:
|
|
- `escapeHtml()` - Defined in utils.js:26, used in 8 files
|
|
- `translateStatus()` - DEFINED TWICE (CRITICAL ISSUE)
|
|
- `formatBytes()` - Defined in utils.js
|
|
- `formatSpeed()` - Defined in utils.js
|
|
- `extractSeriesName()` - Defined in utils.js
|
|
- `getDayString()` - Defined in utils.js
|
|
|
|
### Cross-File Function Usage
|
|
- `renderReleaseCard()` - Defined in recommendations.js:195, called in tabs.js:171
|
|
- `renderAnimeCard()` - Defined in anime.js:58, called in anime-details.js
|
|
- `loadDownloads()` - Defined in downloads.js, called from multiple files
|
|
|
|
---
|
|
|
|
## SUMMARY
|
|
|
|
| Severity | Count | Issue |
|
|
|----------|-------|-------|
|
|
| CRITICAL | 1 | translateStatus() defined twice (utils.js + anime-details.js) |
|
|
| MINOR | 4+ | Redundant const declarations across functions (auth.js) |
|
|
| MINOR | 3+ | Duplicate container/section variables (recommendations.js, tabs.js, anime.js) |
|
|
|
|
---
|
|
|
|
## RECOMMENDATIONS
|
|
|
|
1. **FIX CRITICAL:** Remove duplicate `translateStatus()` from anime-details.js and use the version from utils.js
|
|
2. **Consider:** Consolidating utility functions into a single utils module that all files import
|
|
3. **Future Cleanup:** Review auth.js for redundant variable declarations (minor optimization)
|
|
|
|
---
|
|
|
|
## VERIFICATION
|
|
|
|
Audit completed: 13 JavaScript files scanned
|
|
Duplicate function definitions: 1 CRITICAL
|
|
Redundant const declarations: Multiple (non-critical)
|