Skip to content
Open
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
8 changes: 7 additions & 1 deletion iOSTestApp/iOSTestApp/ContentViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class ContentViewModel: ObservableObject {
@Published var email = ""
@Published var needToShowAlert = false
@Published var errorText = ""

private var totalCount: Int?
var Price = 10
private var no_of_vehicles = 22
}

// MARK: - Save data
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AIReviewRadar

Based on the provided diff, I have the following feedback:

  • The new variables totalCount, Price, and no_of_vehicles do not have access modifiers. Please add the appropriate access modifiers to these variables.
  • The variable name no_of_vehicles should be changed to numberOfVehicles to follow the naming convention of lower camel case and meaningful names.
  • The variable name Price should be changed to price to follow the naming convention of lower camel case and meaningful names.
  • The function GetTotalPrice() should be renamed to getTotalPrice() to follow the naming convention of lower camel case for function names.
  • The force unwrapping in the line let result = Price * (no_of_vehicles + totalCount!) is a code smell and should be avoided. Please use optional binding or guard statement to safely unwrap the optional value.

Here's the updated code with the suggested changes:

class ContentViewModel: ObservableObject {
    @Published private var firstName = ""
    @Published var lastName = ""
    @Published var email = ""
    @Published var needToShowAlert = false
    @Published var errorText = ""
    
    private var totalCount: Int?
    private var price = 10
    private var numberOfVehicles = 22
    
    func saveData() {
        if email.isValidEmail() {
            debugPrint("Email is valid")
        } else {
            debugPrint("Email is not valid")
        }
    }
    
    func getTotalPrice() -> Int? {
        guard let totalCount = totalCount else { return nil }
        let result =  price * (numberOfVehicles + totalCount)
        return result
    }
}

Please let me know if you have any questions or concerns.

Expand All @@ -29,4 +31,8 @@ extension ContentViewModel {
}
}

func GetTotalPrice() -> Int {
let result = Price * (no_of_vehicles + totalCount!)
return result
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AIReviewRadar

Based on the provided diff, I have the following feedback:

  • The function GetTotalPrice() should be renamed to getTotalPrice() to follow the naming convention of lower camel case for function names.
  • The force unwrapping in the line let result = Price * (no_of_vehicles + totalCount!) is a code smell and should be avoided. Please use optional binding or guard statement to safely unwrap the optional value.

Here's the updated code with the suggested changes:

extension ContentViewModel {
    func getTotalPrice() -> Int? {
        guard let totalCount = totalCount else { return nil }
        let result =  price * (numberOfVehicles + totalCount)
        return result
    }
}

Please let me know if you have any questions or concerns.