mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Upgrade Swiftlint and fix warnings
This commit is contained in:
1 parent
abaa14db83
commit
aff924a72b
13 files changed
+37
-24
No files matched your search
@@ -1861,10 +1861,10 @@ extension Database {
|
||||
enum Impl {
|
||||
case trace_v1(String)
|
||||
case trace_v2(
|
||||
sqliteStatement: SQLiteStatement,
|
||||
unexpandedSQL: UnsafePointer<CChar>?,
|
||||
sqlite3_expanded_sql: @convention(c) (OpaquePointer?) -> UnsafeMutablePointer<Int8>?,
|
||||
publicStatementArguments: Bool) // See Configuration.publicStatementArguments
|
||||
sqliteStatement: SQLiteStatement,
|
||||
unexpandedSQL: UnsafePointer<CChar>?,
|
||||
sqlite3_expanded_sql: @convention(c) (OpaquePointer?) -> UnsafeMutablePointer<Int8>?,
|
||||
publicStatementArguments: Bool) // See Configuration.publicStatementArguments
|
||||
}
|
||||
var impl: Impl
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
|
||||
return result
|
||||
}
|
||||
} else {
|
||||
/// There is no unsafe access to a snapshot.
|
||||
// There is no unsafe access to a snapshot.
|
||||
return try read(value)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -121,8 +121,8 @@ public struct SQL {
|
||||
fileprivate func qualified(with alias: TableAlias) -> Element {
|
||||
switch self {
|
||||
case .sql:
|
||||
/// A raw SQL string can't be qualified with a table alias,
|
||||
/// because we can't parse it.
|
||||
// A raw SQL string can't be qualified with a table alias,
|
||||
// because we can't parse it.
|
||||
return self
|
||||
case .subquery:
|
||||
// Subqueries don't need table alias
|
||||
|
||||
@@ -206,9 +206,9 @@ extension SQLRequest: FetchRequest {
|
||||
switch cache {
|
||||
case .none:
|
||||
statement = try db.makeStatement(sql: sql)
|
||||
case .public?:
|
||||
case .public:
|
||||
statement = try db.cachedStatement(sql: sql)
|
||||
case .internal?:
|
||||
case .internal:
|
||||
statement = try db.internalCachedStatement(sql: sql)
|
||||
}
|
||||
try statement.setArguments(context.arguments)
|
||||
|
||||
@@ -1482,7 +1482,7 @@ public struct DatabasePreUpdateEvent {
|
||||
/// The triggering depth of the row update
|
||||
/// Returns:
|
||||
/// 0 if the preupdate callback was invoked as a result of a direct insert,
|
||||
// update, or delete operation;
|
||||
/// update, or delete operation;
|
||||
/// 1 for inserts, updates, or deletes invoked by top-level triggers;
|
||||
/// 2 for changes resulting from triggers called by top-level triggers;
|
||||
/// ... and so forth
|
||||
|
||||
@@ -65,7 +65,7 @@ final class WALSnapshot: Sendable {
|
||||
///
|
||||
/// See <https://www.sqlite.org/c3ref/snapshot_cmp.html>.
|
||||
func compare(_ other: WALSnapshot) -> CInt {
|
||||
return sqlite3_snapshot_cmp(sqliteSnapshot, other.sqliteSnapshot)
|
||||
sqlite3_snapshot_cmp(sqliteSnapshot, other.sqliteSnapshot)
|
||||
}
|
||||
#else
|
||||
static let available = false
|
||||
|
||||
@@ -86,7 +86,7 @@ public struct FTS5TokenizerDescriptor {
|
||||
///
|
||||
/// - parameters:
|
||||
/// - base: An eventual wrapping tokenizer which replaces the
|
||||
// default unicode61() base tokenizer.
|
||||
/// default unicode61() base tokenizer.
|
||||
///
|
||||
/// See <https://www.sqlite.org/fts5.html#porter_tokenizer>
|
||||
public static func porter(wrapping base: FTS5TokenizerDescriptor? = nil) -> FTS5TokenizerDescriptor {
|
||||
|
||||
@@ -22,7 +22,7 @@ struct SQLForeignKeyRequest {
|
||||
|
||||
/// The (origin, destination) column pairs that join a left table to a right table.
|
||||
func fetchForeignKeyMapping(_ db: Database) throws -> ForeignKeyMapping {
|
||||
if let originColumns, let destinationColumns = destinationColumns {
|
||||
if let originColumns, let destinationColumns {
|
||||
// Total information: no need to query the database schema.
|
||||
GRDBPrecondition(originColumns.count == destinationColumns.count, "Number of columns don't match")
|
||||
let mapping = zip(originColumns, destinationColumns).map {
|
||||
|
||||
@@ -1927,7 +1927,7 @@ public final class ColumnDefinition {
|
||||
switch notNullConflictResolution {
|
||||
case .none:
|
||||
break
|
||||
case .abort?:
|
||||
case .abort:
|
||||
chunks.append("NOT NULL")
|
||||
case let conflictResolution?:
|
||||
chunks.append("NOT NULL ON CONFLICT")
|
||||
|
||||
@@ -700,7 +700,7 @@ extension TableRecord {
|
||||
|
||||
/// Returns an error for a record that does not exist in the database.
|
||||
public static func recordNotFound(key: [String: (any DatabaseValueConvertible)?]) -> RecordError {
|
||||
return RecordError.recordNotFound(
|
||||
RecordError.recordNotFound(
|
||||
databaseTableName: databaseTableName,
|
||||
key: key.mapValues { $0?.databaseValue ?? .null })
|
||||
}
|
||||
@@ -713,7 +713,7 @@ extension TableRecord where Self: Identifiable, ID: DatabaseValueConvertible {
|
||||
/// - returns: ``RecordError/recordNotFound(databaseTableName:key:)``, or
|
||||
/// any error that prevented the `RecordError` from being constructed.
|
||||
public static func recordNotFound(_ db: Database, id: Self.ID) -> any Error {
|
||||
return recordNotFound(db, key: id)
|
||||
recordNotFound(db, key: id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ func GRDBPrecondition(
|
||||
file: StaticString = #file,
|
||||
line: UInt = #line)
|
||||
{
|
||||
/// Custom precondition function which aims at solving
|
||||
/// <https://bugs.swift.org/browse/SR-905> and
|
||||
/// <https://github.com/groue/GRDB.swift/issues/37>
|
||||
// Custom precondition function which aims at solving
|
||||
// <https://bugs.swift.org/browse/SR-905> and
|
||||
// <https://github.com/groue/GRDB.swift/issues/37>
|
||||
if !condition() {
|
||||
fatalError(message(), file: file, line: line)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ import Foundation
|
||||
/// reducing stage.
|
||||
///
|
||||
/// **Notify** is calling user callbacks, in case of database change or error.
|
||||
final class ValueWriteOnlyObserver<Writer: DatabaseWriter, Reducer: ValueReducer, Scheduler: ValueObservationScheduler> {
|
||||
final class ValueWriteOnlyObserver<
|
||||
Writer: DatabaseWriter,
|
||||
Reducer: ValueReducer,
|
||||
Scheduler: ValueObservationScheduler>
|
||||
{
|
||||
// MARK: - Configuration
|
||||
//
|
||||
// Configuration is not mutable.
|
||||
|
||||
+13
-4
@@ -6,13 +6,14 @@ disabled_rules:
|
||||
- cyclomatic_complexity
|
||||
- duplicate_enum_cases
|
||||
- file_length
|
||||
- for_where
|
||||
- force_cast
|
||||
- force_try
|
||||
- for_where
|
||||
- function_body_length
|
||||
- function_parameter_count
|
||||
- identifier_name
|
||||
- is_disjoint
|
||||
- large_tuple
|
||||
- nesting
|
||||
- opening_brace
|
||||
- redundant_optional_initialization
|
||||
@@ -25,11 +26,10 @@ disabled_rules:
|
||||
- unused_setter_value
|
||||
|
||||
opt_in_rules:
|
||||
- anyobject_protocol
|
||||
- array_init
|
||||
- capture_variable
|
||||
- closure_spacing
|
||||
- collection_alignment
|
||||
- comma_inheritance
|
||||
- contains_over_filter_count
|
||||
- contains_over_filter_is_empty
|
||||
- contains_over_first_not_nil
|
||||
@@ -48,20 +48,29 @@ opt_in_rules:
|
||||
- last_where
|
||||
- legacy_multiple
|
||||
- legacy_random
|
||||
- local_doc_comment
|
||||
- lower_acl_than_parent
|
||||
- modifier_order
|
||||
- no_extension_access_modifier
|
||||
- optional_enum_case_matching
|
||||
- overridden_super_call
|
||||
- pattern_matching_keywords
|
||||
- prohibited_super_call
|
||||
- reduce_into
|
||||
- redundant_type_annotation
|
||||
- shorthand_optional_binding
|
||||
- sorted_first_last
|
||||
- sorted_imports
|
||||
- toggle_bool
|
||||
- unused_capture_list
|
||||
- vertical_parameter_alignment_on_call
|
||||
- yoda_condition
|
||||
|
||||
analyzer_rules:
|
||||
- capture_variable
|
||||
- typesafe_array_init
|
||||
- unused_declaration
|
||||
- unused_import
|
||||
- yoda_condition
|
||||
|
||||
vertical_whitespace:
|
||||
max_empty_lines: 2
|
||||
|
||||
Reference in new issue
Block a user