Skip to content

Commit

Permalink
Feature/enable swiftlint for non intelusers (#227)
Browse files Browse the repository at this point in the history
* Update project.pbxproj

update environment variable to point home brew bin folder, this helps non intel users to run swiftlint and get warning in xcode.

* worked on a swiftlint warnings, updated swiflint.yml file

changes done in swiftlint.yml file in exluded tag to ignore swiflint warnings in files generated by amplify.

* Fixed swiftlint warnings exclude generated file from swiftlint.yml file

Excluding generated files from SwiftLint analysis helps prevent unnecessary warnings and errors that might arise from the analysis of automatically generated code.

* Update .gitignore file to exclude AutoMockable generated file

Added the path in .gitignore file to exclude the AutoMockable generated errors

* Fixed swiftlint warnings

Fixed issues related to swiftlint warnings so as to improve the code quality.

* Update ProfileViewController.swift
  • Loading branch information
Suraj1999 authored Nov 11, 2023
1 parent 301df07 commit c164d5e
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end

# Sourcery generated file
animealTests/Sourcery/Generated/
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ excluded:
- ${PWD}/DerivedData
- Tools
- amplify/generated
- animealTests/Sourcery/Generated

disabled_rules:
- discarded_notification_center_observer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ class PlaceholderRangeCalculator {
let textLeftSlice = text.leftSlice(end: before)
let patternLeftSlice = textPattern.leftSlice(limit: textLeftSlice.count)
var result = 0
for (textSliceChar, patternSliceChar) in zip(textLeftSlice, patternLeftSlice) {
if textSliceChar == patternSliceChar {
for (textSliceChar, patternSliceChar) in zip(textLeftSlice, patternLeftSlice)
where textSliceChar == patternSliceChar {
result += 1
}
}
return result
}

Expand Down
2 changes: 0 additions & 2 deletions Services/Sources/Services/Camera/CameraService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ public protocol CameraServiceProtocol {

public extension CameraServiceProtocol {
var cameraAuthorizationStatus: AVAuthorizationStatus {
get {
return AVCaptureDevice.authorizationStatus(for: .video)
}
}

func requestCameraPermissionNative() async {
Expand Down
2 changes: 0 additions & 2 deletions Services/Sources/Services/Location/LocationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public final class LocationService {
// MARK: - LocationService
extension LocationService: LocationServiceProtocol {
public var locationStatus: CLAuthorizationStatus {
get {
return locationManager.authorizationStatus
}
}

public func removeDelegate(_ delegate: LocationServiceDelegate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ struct DataStoreAmplifyConverter: AmplifyDataStoreConverting, DataStoreAmplifyCo

func convertAmplifyError(_ amplifyError: StorageError) -> Services.DataStoreError {
switch amplifyError {
case .accessDenied(let errorDescription, let recoverySuggestion, let underlyingError):
case let .accessDenied(errorDescription, recoverySuggestion, underlyingError):
return .accessDenied(errorDescription, recoverySuggestion, underlyingError)
case .authError(let errorDescription, let recoverySuggestion, let underlyingError):
case let .authError(errorDescription, recoverySuggestion, underlyingError):
return .authError(errorDescription, recoverySuggestion, underlyingError)
case .configuration(let errorDescription, let recoverySuggestion, let underlyingError):
case let .configuration(errorDescription, recoverySuggestion, underlyingError):
return .configuration(errorDescription, recoverySuggestion, underlyingError)
case .httpStatusError(let status, let recoverySuggestion, let underlyingError):
case let .httpStatusError(status, recoverySuggestion, underlyingError):
return .httpStatusError(status, recoverySuggestion, underlyingError)
case .keyNotFound(let key, let errorDescription, let recoverySuggestion, let underlyingError):
case let .keyNotFound(key, errorDescription, recoverySuggestion, underlyingError):
return .keyNotFound(key, errorDescription, recoverySuggestion, underlyingError)
case .localFileNotFound(let errorDescription, let recoverySuggestion, let underlyingError):
case let .localFileNotFound(errorDescription, recoverySuggestion, underlyingError):
return .localFileNotFound(errorDescription, recoverySuggestion, underlyingError)
case .service(let errorDescription, let recoverySuggestion, let underlyingError):
case let .service(errorDescription, recoverySuggestion, underlyingError):
return .service(errorDescription, recoverySuggestion, underlyingError)
case .unknown(let errorDescription, let underlyingError):
case let .unknown(errorDescription, underlyingError):
return .unknown(errorDescription, underlyingError)
case .validation(let field, let errorDescription, let recoverySuggestion, let underlyingError):
case let .validation(field, errorDescription, recoverySuggestion, underlyingError):
return .validation(field, errorDescription, recoverySuggestion, underlyingError)
}
}
Expand Down
10 changes: 5 additions & 5 deletions animeal/src/Flows/AttachPhoto/AttachPhotoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ private extension AttachPhotoViewController {
attachingPhotoView.onTapAttachPhoto = { [weak self] in
if let granted = self?.viewModel.grantCameraPermission(),
granted {
let vc = UIImagePickerController()
vc.sourceType = .camera
vc.allowsEditing = true
vc.delegate = self
self?.present(vc, animated: true)
let viewController = UIImagePickerController()
viewController.sourceType = .camera
viewController.allowsEditing = true
viewController.delegate = self
self?.present(viewController, animated: true)
}
}

Expand Down
4 changes: 2 additions & 2 deletions animeal/src/Flows/AttachPhoto/AttachPhotoViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ private extension AttachPhotoViewModel {
}
do {
progressModel.isVisible = true
return try await model.uploadMediaContent(data: data, progressListener: { progress in
return try await model.uploadMediaContent(data: data) { progress in
DispatchQueue.main.async {
progressModel.updateProgress(progress)
}
})
}
} catch {
progressModel.isVisible = false
throw error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ final class FeedingPointDetailsModel: FeedingPointDetailsModelProtocol, FeedingP
let history = try await context.feedingPointsService.fetchFeedingHistory(for: fullFeedingPoint.identifier)
guard !history.isEmpty else { return [] }

let sortedByDateHistory = history.sorted(by: { $0.updatedAt > $1.updatedAt })
let sortedByDateHistory = history.sorted { $0.updatedAt > $1.updatedAt }

let historyUsers = sortedByDateHistory.map { $0.userId }
let namesMap = try await context.profileService.fetchUserNames(for: historyUsers)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ final class DonateModel: DonateModelProtocol {
private var paymentMethods: [PaymentMethod] = []

// MARK: - Initialization
init(context: Context = AppDelegate.shared.context,
mapper: DonatePaymentMethodMappable = DonatePaymentMethodMapper()) {
init(
context: Context = AppDelegate.shared.context,
mapper: DonatePaymentMethodMappable = DonatePaymentMethodMapper()
) {
self.context = context
self.mapper = mapper
}
Expand All @@ -27,7 +29,7 @@ final class DonateModel: DonateModelProtocol {
}

func getPaymentMethod(for id: String) -> PaymentMethod? {
paymentMethods.first(where: { $0.id == id })
paymentMethods.first { $0.id == id }
}

func fetchIconURL(for key: String) async throws -> URL? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ final class FAQModel: FAQModelProtocol {
private let mapper: QuestionMappable

// MARK: - Initialization
init(context: Context = AppDelegate.shared.context,
mapper: QuestionMappable = QuestionMapper()) {
init(
context: Context = AppDelegate.shared.context,
mapper: QuestionMappable = QuestionMapper()
) {
self.context = context
self.mapper = mapper
}
Expand Down
3 changes: 2 additions & 1 deletion animeal/src/Flows/Profile/ProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ final class ProfileViewController: BaseViewController, ProfileViewable {
navigationItem.hidesBackButton = viewConfiguration.hidesBackButton
if !viewConfiguration.hidesBackButton {
navigationItem.hidesBackButton = true
let backButton = UIBarButtonItem(image: UIImage(named: Asset.Images.arrowBackOffset.name), style: .plain, target: self, action: #selector(backTapped))
let image = UIImage(named: Asset.Images.arrowBackOffset.name)
let backButton = UIBarButtonItem(image: image, style: .plain, target: self, action: #selector(backTapped))
navigationItem.leftBarButtonItem = backButton
}
}
Expand Down

0 comments on commit c164d5e

Please sign in to comment.