Skip to content

Conversation

mauricecarrier7
Copy link
Contributor

What's this do?
Code base linting and clean up

Why are we doing this? (w/ Notion link if applicable)
Improve code base

How should this be tested? / Do these changes have associated tests?
No additional testing necessary

Dependencies for merging? Releasing to production?
https://github.com/ThePalaceProject/ios-audiobooktoolkit/pull/137/files

Does this include changes that require a new Palace build for QA?
No

Has the application documentation been updated for these changes?
N/A

Did someone actually run this code to verify it works?
@mauricecarrier7

- Applied SwiftLint --fix to resolve automatically fixable issues
- Fixed trailing commas, implicit optional initialization, redundant code
- Corrected whitespace, void returns, and other formatting issues
- Added migration configuration for gradual linting adoption
- Part of effort to reduce violations from 1,171 to under 800
- Applied additional auto-corrections from SwiftLint --fix
- Cleaned up remaining automatically fixable issues
- Total violations reduced to 865 (from original 2,241)
- Target: reduce below 800 violations
- Replace force casts with safe casting in TPPSettingsView.swift (Bundle info keys)
- Replace force cast with guard let in BarcodeScanner.swift (AVMetadataObject transform)
- Replace force try with proper error handling in SEMigrations.swift (FileManager URL)

These changes prevent potential runtime crashes from:
- Missing bundle info dictionary keys
- Failed metadata object transformations
- FileManager directory creation failures

Addresses most critical force_cast and force_try violations.
- Replace dangerous SQLite force cast/try with proper error handling in TPPNetworkQueue.swift
- Replace Bundle info dictionary force cast with safe casting in TPPSettings+SE.swift
- Replace Bundle version force cast with guard let in TPPMigrationManager.swift

These changes prevent critical crashes from:
- SQLite database access failures
- Missing bundle info dictionary keys
- Failed type casting in core database operations

Reduced serious violations: 240 → 233 (-7)
Total violations: 860 → 854 (-6)
- Replace BGAppRefreshTask force cast with safe guard let in TPPAppDelegate.swift
- Replace Bundle identifier force cast with guard let in TPPBookContentMetadataFilesHelper.swift
- Replace PDFSelection copy force cast with guard let in TPPPDFDocument.swift

These prevent crashes from:
- Background task type mismatches
- Missing bundle identifiers
- PDF selection copy failures

Continuing systematic crash prevention effort.
@mauricecarrier7 mauricecarrier7 self-assigned this Sep 29, 2025
@mauricecarrier7 mauricecarrier7 marked this pull request as ready for review September 29, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant