Skip to content

Commit

Permalink
chore: fix fmt script and run it
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Aug 29, 2024
1 parent 094dcaf commit 3cc5701
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 169 deletions.
10 changes: 5 additions & 5 deletions ios/Plugin/CapacitorSQLite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ enum CapacitorSQLiteError: Error {

// MARK: - CheckEncryptionSecret

@objc public func checkEncryptionSecret(passphrase: String) throws -> NSNumber {
@objc public func checkEncryptionSecret(passphrase: String) throws -> NSNumber {
guard isInit else {
throw CapacitorSQLiteError.failed(message: initMessage)
}
Expand Down Expand Up @@ -557,7 +557,7 @@ enum CapacitorSQLiteError: Error {
// MARK: - GetVersion

@objc public func getVersion(_ dbName: String, readonly: Bool)
throws -> NSNumber {
throws -> NSNumber {
guard isInit else {
throw CapacitorSQLiteError.failed(message: initMessage)
}
Expand Down Expand Up @@ -585,7 +585,7 @@ enum CapacitorSQLiteError: Error {
UtilsDownloadFromHTTP.download(databaseLocation: databaseLocation,
url: url) { ( result) in
switch result {
case .success(_):
case .success:
self.retHandler.rResult(call: call)
return
case .failure(let error):
Expand Down Expand Up @@ -624,7 +624,7 @@ enum CapacitorSQLiteError: Error {

@objc public func checkConnectionsConsistency(_ dbNames: [String],
openModes: [String])
throws -> NSNumber {
throws -> NSNumber {
guard isInit else {
throw CapacitorSQLiteError.failed(message: initMessage)
}
Expand Down Expand Up @@ -1033,7 +1033,7 @@ enum CapacitorSQLiteError: Error {
account: account)
if !isEncryption &&
(state.rawValue == "ENCRYPTEDGLOBALSECRET" ||
state.rawValue == "ENCRYPTEDSECRET") {
state.rawValue == "ENCRYPTEDSECRET") {
var msg = "Cannot delete an Encrypted database with "
msg += "No Encryption set in capacitor.config"
throw CapacitorSQLiteError.failed(message: msg)
Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Database {
let msg: String = "Failed in deleteBackupDB \(message)"
throw DatabaseError.open(message: msg)
} catch UtilsUpgradeError.onUpgradeFailed(let message) {
//restore the database
// restore the database
do {
try UtilsSQLCipher
.restoreDB(databaseLocation: databaseLocation,
Expand Down
14 changes: 7 additions & 7 deletions ios/Plugin/ImportExportJson/ExportToJson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class ExportToJson {
}

switch expMode {
case "partial" :
case "partial":
tables = try ExportToJson
.getTablesPartial(mDB: mDB,
resTables: resTables)
Expand Down Expand Up @@ -1199,9 +1199,9 @@ class ExportToJson {
row.append(val)
} else if values[pos][names[jpos]] is Int64 && (
INTEGERAFFINITY.contains(types[jpos].uppercased()) ||
INTEGERAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos].uppercased())) {
INTEGERAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos].uppercased())) {
guard let val = values[pos][names[jpos]] as? Int64
else {
throw ExportToJsonError.createValues(
Expand All @@ -1210,8 +1210,8 @@ class ExportToJson {
row.append(val)
} else if values[pos][names[jpos]] is Int64 && (
REALAFFINITY.contains(types[jpos].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased())) {
NUMERICAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased())) {
guard let val = values[pos][names[jpos]] as? Int64
else {
throw ExportToJsonError.createValues(
Expand All @@ -1221,7 +1221,7 @@ class ExportToJson {
} else if values[pos][names[jpos]] is Double && (
REALAFFINITY.contains(types[jpos].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased())) {
.components(separatedBy: "(")[0].uppercased())) {
guard let val = values[pos][names[jpos]] as? Double
else {
throw ExportToJsonError.createValues(
Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/Models/KeychainServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class KeychainWrapper {
throw KeychainWrapperError(type: .unableToConvertToString)
}

//5
// 5
return value
}

Expand Down
4 changes: 2 additions & 2 deletions ios/Plugin/Utils/UtilsBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class UtilsBinding {
let sortedValues = extractSortedValues(from: dict)
let data: Data = Data(sortedValues)
sqlite3_bind_blob(handle, Int32(idx), data.bytes,
Int32(data.bytes.count), SQLITETRANSIENT)
Int32(data.bytes.count), SQLITETRANSIENT)
}
} else {
throw UtilsSQLCipherError.bindFailed
Expand All @@ -95,5 +95,5 @@ class UtilsBinding {
return false
}
return true
}
}
}
8 changes: 4 additions & 4 deletions ios/Plugin/Utils/UtilsDelete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class UtilsDelete {
// update all related element
// set sql_deleted = 1 and last_modified
// tableName
//update all by sending return true
// update all by sending return true
results = try upDateWhereForCascade(
results: result)

Expand Down Expand Up @@ -342,7 +342,7 @@ class UtilsDelete {
colNames: [String], values: [Any])
throws {
var lastId: Int64 = -1
//update sql_deleted for this references
// update sql_deleted for this references
let stmt = "UPDATE \(tableName) SET \(setStmt) \(whereStmt)"
var selValues: [Any] = []
if !values.isEmpty {
Expand Down Expand Up @@ -450,8 +450,8 @@ class UtilsDelete {
throw UtilsDeleteError.getRefs(message: msg)
}
} else {
let msg = "getRefs: Error creating tableNameMatch "
throw UtilsDeleteError.getRefs(message: msg)
let msg = "getRefs: Error creating tableNameMatch "
throw UtilsDeleteError.getRefs(message: msg)
}

// Regular expression pattern to match the FOREIGN KEY
Expand Down
4 changes: 2 additions & 2 deletions ios/Plugin/Utils/UtilsDownloadFromHTTP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class UtilsDownloadFromHTTP {
class func download(databaseLocation: String, url: String,
completion: @escaping (Result<Bool, UtilsDownloadError>) -> Void) {
guard let fileDetails = getFileDetails(url: url),
let fileExtension = fileDetails.extension ,
fileExtension == "db" || fileExtension == "zip" else {
let fileExtension = fileDetails.extension,
fileExtension == "db" || fileExtension == "zip" else {
let msg = "download: Not a .zip or .db url"
print("\(msg)")
completion(.failure(UtilsDownloadError.downloadFromHTTPFailed(message: msg)))
Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/Utils/UtilsDrop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class UtilsDrop {
.getTriggersNamesFailed(message: message)
}
}
//1234567890123456789012345678901234567890123456789012345678901234567890
// 1234567890123456789012345678901234567890123456789012345678901234567890
// MARK: - dropTriggers

class func dropTriggers(mDB: Database) throws -> Int {
Expand Down
34 changes: 17 additions & 17 deletions ios/Plugin/Utils/UtilsSQLCipher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ class UtilsSQLCipher {
var result: [[String: Any]] = []
var retMode: String
let stmtType = sqlStmt
.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: " ")
.first?.capitalized ?? ""
.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: " ")
.first?.capitalized ?? ""

if #available(iOS 15, *) {
retMode = returnMode
Expand Down Expand Up @@ -570,9 +570,9 @@ class UtilsSQLCipher {
var result: [[String: Any]] = []
let initLastId = Int64(sqlite3_last_insert_rowid(mDB.mDb))
let stmtType = sqlStmt
.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: " ")
.first?.capitalized ?? ""
.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: " ")
.first?.capitalized ?? ""

if stmtType == "DELETE" &&
names.count > 0 {
Expand Down Expand Up @@ -986,17 +986,17 @@ class UtilsSQLCipher {
}
}
} else {
let resp = try UtilsSQLCipher
.prepareSQL(mDB: mDB, sql: sql, values: values,
fromJson: false, returnMode: returnMode)
lastId = resp.0
respSet = resp.1
if lastId == -1 {
let message: String = "lastId < 0"
throw UtilsSQLCipherError.executeSet(
message: message)
}
response = addToResponse(response: response, respSet: respSet)
let resp = try UtilsSQLCipher
.prepareSQL(mDB: mDB, sql: sql, values: values,
fromJson: false, returnMode: returnMode)
lastId = resp.0
respSet = resp.1
if lastId == -1 {
let message: String = "lastId < 0"
throw UtilsSQLCipherError.executeSet(
message: message)
}
response = addToResponse(response: response, respSet: respSet)
}
}

Expand Down
Loading

0 comments on commit 3cc5701

Please sign in to comment.