Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ echo "🔍 Running SwiftLint on staged files…"
# Lint only the staged files (faster than full project)
echo "$staged_swift_files" | while read -r file; do
if [[ -f "$file" ]]; then
swiftlint lint --quiet --strict --use-script-input-files <<< "$file" || {
swiftlint lint --quiet --strict "$file" || {
echo ""
echo "❌ SwiftLint failed. Fix the issues above, then re-stage and commit."
echo " To bypass (NOT recommended), use: git commit --no-verify"
Expand Down
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ force_cast:
force_try:
severity: error # error: same
force_unwrapping:
severity: warning # warning today → bump to error after cleanup PR
severity: error

# Custom project rules
custom_rules:
Expand Down
9 changes: 5 additions & 4 deletions Savely/Managers/CameraManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ class CameraManager: NSObject, ObservableObject {
}

func setPreviewLayer(to view: UIView) {
previewLayer = AVCaptureVideoPreviewLayer(session: session)
previewLayer?.videoGravity = .resizeAspectFill
previewLayer?.frame = view.bounds
view.layer.insertSublayer(previewLayer!, at: 0)
let layer = AVCaptureVideoPreviewLayer(session: session)
layer.videoGravity = .resizeAspectFill
layer.frame = view.bounds
previewLayer = layer
view.layer.insertSublayer(layer, at: 0)
}

func capturePhoto() {
Expand Down
6 changes: 5 additions & 1 deletion Savely/Models/ExpenseModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ extension ExpenseModel {
print("Fetching expenses from \(startDate) to \(endDate)")

// Precompute adjusted end date
let adjustedEndDate = Calendar.current.startOfDay(for: Calendar.current.date(byAdding: .day, value: 1, to: endDate)!)
guard let nextDay = Calendar.current.date(byAdding: .day, value: 1, to: endDate) else {
print("Error computing adjusted end date for expense fetch")
return []
}
let adjustedEndDate = Calendar.current.startOfDay(for: nextDay)

let fetchDescriptor = FetchDescriptor<ExpenseModel>(
predicate: #Predicate {
Expand Down
6 changes: 5 additions & 1 deletion Savely/Models/IncomeModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ extension IncomeModel {
print("Fetching incomes from \(startDate) to \(endDate)")

// Precompute adjusted end date
let adjustedEndDate = Calendar.current.startOfDay(for: Calendar.current.date(byAdding: .day, value: 1, to: endDate)!)
guard let nextDay = Calendar.current.date(byAdding: .day, value: 1, to: endDate) else {
print("Error computing adjusted end date for income fetch")
return []
}
let adjustedEndDate = Calendar.current.startOfDay(for: nextDay)

let fetchDescriptor = FetchDescriptor<IncomeModel>(
predicate: #Predicate {
Expand Down
7 changes: 5 additions & 2 deletions Savely/Utilities/OpenAIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class OpenAIClient {
}

func fetchTip(prompt: String) async -> String? {
let url = URL(string: "https://api.openai.com/v1/chat/completions")!

guard let url = URL(string: "https://api.openai.com/v1/chat/completions") else {
return nil
}


// Construir el mensaje para el modelo
let messages = [
OpenAIChatMessage(role: "system", content: "Eres un asistente financiero."),
Expand Down
2 changes: 1 addition & 1 deletion Savely/Utilities/SignInWithAppleHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@

@MainActor
private func topViewController(controller: UIViewController? = nil) -> UIViewController? {
let controller = controller ?? UIApplication.shared.keyWindow?.rootViewController

Check warning on line 184 in Savely/Utilities/SignInWithAppleHelper.swift

View workflow job for this annotation

GitHub Actions / Build & test

'keyWindow' was deprecated in iOS 13.0: Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes

if let navigationController = controller as? UINavigationController {
return topViewController(controller: navigationController.visibleViewController)
Expand Down Expand Up @@ -231,8 +231,8 @@
}
}

extension UIViewController: ASAuthorizationControllerPresentationContextProviding {

Check warning on line 234 in Savely/Utilities/SignInWithAppleHelper.swift

View workflow job for this annotation

GitHub Actions / Build & test

extension declares a conformance of imported type 'UIViewController' to imported protocol 'ASAuthorizationControllerPresentationContextProviding'; this will not behave correctly if the owners of 'UIKit' introduce this conformance in the future

Check warning on line 234 in Savely/Utilities/SignInWithAppleHelper.swift

View workflow job for this annotation

GitHub Actions / Build & test

extension declares a conformance of imported type 'UIViewController' to imported protocol 'ASAuthorizationControllerPresentationContextProviding'; this will not behave correctly if the owners of 'UIKit' introduce this conformance in the future
public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
return self.view.window!
return self.view.window ?? ASPresentationAnchor()

Check warning on line 236 in Savely/Utilities/SignInWithAppleHelper.swift

View workflow job for this annotation

GitHub Actions / Build & test

'init()' was deprecated in iOS 26.0: Use init(windowScene:) instead.
}
}
6 changes: 4 additions & 2 deletions Savely/ViewModels/Dashboard/ReportsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

var modelContext: ModelContext? {
didSet {
guard let modelContext = modelContext else { return }

Check warning on line 21 in Savely/ViewModels/Dashboard/ReportsViewModel.swift

View workflow job for this annotation

GitHub Actions / Build & test

value 'modelContext' was defined but never used; consider replacing with boolean test
fetchReportData()
}
}
Expand Down Expand Up @@ -74,7 +74,8 @@
print("Fetching weekly incomes...")

let adjustedStartDate = Calendar.current.startOfDay(for: startDate)
let adjustedEndDate = Calendar.current.startOfDay(for: Calendar.current.date(byAdding: .day, value: 1, to: endDate)!)
guard let nextDay = Calendar.current.date(byAdding: .day, value: 1, to: endDate) else { return [] }
let adjustedEndDate = Calendar.current.startOfDay(for: nextDay)

let fetchDescriptor = FetchDescriptor<IncomeModel>(
predicate: #Predicate {
Expand All @@ -89,7 +90,8 @@
print("Fetching weekly expenses...")

let adjustedStartDate = Calendar.current.startOfDay(for: startDate)
let adjustedEndDate = Calendar.current.startOfDay(for: Calendar.current.date(byAdding: .day, value: 1, to: endDate)!)
guard let nextDay = Calendar.current.date(byAdding: .day, value: 1, to: endDate) else { return [] }
let adjustedEndDate = Calendar.current.startOfDay(for: nextDay)

let fetchDescriptor = FetchDescriptor<ExpenseModel>(
predicate: #Predicate {
Expand Down
6 changes: 4 additions & 2 deletions Savely/ViewModels/ProfileTab/ProfileViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class ProfileViewModel: ObservableObject {
private func fetchWeeklyIncome(from startDate: Date, to endDate: Date, in context: ModelContext) async throws -> [IncomeModel] {
print("fetchWeeklyIncome: Fetching incomes...")
let adjustedStartDate = Calendar.current.startOfDay(for: startDate)
let adjustedEndDate = Calendar.current.startOfDay(for: Calendar.current.date(byAdding: .day, value: 1, to: endDate)!)
guard let nextDay = Calendar.current.date(byAdding: .day, value: 1, to: endDate) else { return [] }
let adjustedEndDate = Calendar.current.startOfDay(for: nextDay)

let fetchDescriptor = FetchDescriptor<IncomeModel>(
predicate: #Predicate {
Expand All @@ -139,7 +140,8 @@ class ProfileViewModel: ObservableObject {
private func fetchWeeklyExpenses(from startDate: Date, to endDate: Date, in context: ModelContext) async throws -> [ExpenseModel] {
print("fetchWeeklyExpenses: Fetching expenses...")
let adjustedStartDate = Calendar.current.startOfDay(for: startDate)
let adjustedEndDate = Calendar.current.startOfDay(for: Calendar.current.date(byAdding: .day, value: 1, to: endDate)!)
guard let nextDay = Calendar.current.date(byAdding: .day, value: 1, to: endDate) else { return [] }
let adjustedEndDate = Calendar.current.startOfDay(for: nextDay)

let fetchDescriptor = FetchDescriptor<ExpenseModel>(
predicate: #Predicate {
Expand Down
2 changes: 1 addition & 1 deletion Savely/Views/MainNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ struct WarmQuickDepositView: View {

Button(action: saveDeposit) {
let goalName = selectedGoal.map { $0.name.components(separatedBy: ",").first ?? $0.name }
Text(goalName != nil ? "Add $\(Int(selectedPreset)) to \(goalName!)" : "Select a goal")
Text(goalName.map { "Add $\(Int(selectedPreset)) to \($0)" } ?? "Select a goal")
.font(.system(size: 15, weight: .semibold)).foregroundStyle(.white)
.frame(maxWidth: .infinity).frame(height: 50)
.background(selectedGoal != nil ? Color.warmGreen : Color.warmInkMuted)
Expand Down
Loading