Skip to content

Commit b4f3a83

Browse files
committed
Remove SwiftLint warning
If we don't have warnings about explicit nil initialization, then we have a warning about the name of a disabled rule which is now deprecated. In all cases, we have a warning. So let's just write 2025 Swift, ignore that rule, and call it a day.
1 parent 7cd2a45 commit b4f3a83

File tree

11 files changed

+21
-22
lines changed

11 files changed

+21
-22
lines changed

GRDB/Core/Configuration.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public struct Configuration: Sendable {
8787
/// with the number of snapshots.
8888
///
8989
/// The default configuration label is nil.
90-
public var label: String? = nil
90+
public var label: String?
9191

9292
/// A boolean value indicating whether SQLite 3.29+ interprets
9393
/// double-quoted strings as string literals when they does not match any
@@ -329,7 +329,7 @@ public struct Configuration: Sendable {
329329

330330
/// The behavior in case of SQLITE_BUSY error, for read-only connections.
331331
/// If nil, GRDB picks a default one.
332-
var readonlyBusyMode: Database.BusyMode? = nil
332+
var readonlyBusyMode: Database.BusyMode?
333333

334334
/// The maximum number of concurrent reader connections.
335335
///
@@ -387,15 +387,15 @@ public struct Configuration: Sendable {
387387
/// ``qos`` property.
388388
///
389389
/// The default is nil.
390-
public var targetQueue: DispatchQueue? = nil
390+
public var targetQueue: DispatchQueue?
391391

392392
/// The target dispatch queue for write database accesses.
393393
///
394394
/// If this queue is nil, writer connections are controlled
395395
/// by ``targetQueue``.
396396
///
397397
/// The default is nil.
398-
public var writeTargetQueue: DispatchQueue? = nil
398+
public var writeTargetQueue: DispatchQueue?
399399

400400
#if os(iOS)
401401
/// A boolean value indicating whether the database connection releases

GRDB/Core/Database+Schema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ extension Database {
571571
// We don't use `try makeStatement(sql:)` in order to avoid throwing an
572572
// error (this annoys users who set a breakpoint on Swift errors).
573573
let sql = "SELECT rowid AS checkWithoutRowidOptimization FROM \(table.quotedDatabaseIdentifier)"
574-
var statement: SQLiteStatement? = nil
574+
var statement: SQLiteStatement?
575575
let code = sqlite3_prepare_v2(sqliteConnection, sql, -1, &statement, nil)
576576
defer { sqlite3_finalize(statement) }
577577
return code == SQLITE_OK
@@ -743,7 +743,7 @@ extension Database {
743743
id: Int,
744744
destinationTable: String,
745745
mapping: [(origin: String, destination: String?, seq: Int)])] = []
746-
var previousId: Int? = nil
746+
var previousId: Int?
747747
for row in try Row.fetchAll(self, sql: """
748748
PRAGMA \(table.schemaID.sql).foreign_key_list(\(table.name.quotedDatabaseIdentifier))
749749
""")

GRDB/Core/Database+Statements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ extension SQLStatementCursor: Cursor {
387387
let baseAddress = buffer.baseAddress! // never nil because the buffer contains the trailing \0.
388388

389389
// Compile next statement
390-
var statementEnd: UnsafePointer<CChar>? = nil
390+
var statementEnd: UnsafePointer<CChar>?
391391
let statement = try Statement(
392392
database: database,
393393
statementStart: baseAddress + offset,

GRDB/Core/Database.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
169169
/// connection has been opened is an SQLite misuse, and has no effect.
170170
///
171171
/// Related SQLite documentation: <https://www.sqlite.org/errlog.html>
172-
nonisolated(unsafe) public static var logError: LogErrorFunction? = nil {
172+
nonisolated(unsafe) public static var logError: LogErrorFunction? {
173173
didSet {
174174
if logError != nil {
175175
_registerErrorLogCallback { (_, code, message) in
@@ -459,7 +459,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
459459

460460
private static func openConnection(path: String, flags: CInt) throws -> SQLiteConnection {
461461
// See <https://www.sqlite.org/c3ref/open.html>
462-
var sqliteConnection: SQLiteConnection? = nil
462+
var sqliteConnection: SQLiteConnection?
463463
let code = sqlite3_open_v2(path, &sqliteConnection, flags, nil)
464464
guard code == SQLITE_OK else {
465465
// https://www.sqlite.org/c3ref/open.html
@@ -1286,7 +1286,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
12861286

12871287
// Don't return String.fetchOne(self, sql: "PRAGMA journal_mode"), so
12881288
// that we don't create an infinite loop in checkForSuspensionViolation(from:)
1289-
var statement: SQLiteStatement? = nil
1289+
var statement: SQLiteStatement?
12901290
let sql = "PRAGMA journal_mode"
12911291
sqlite3_prepare_v2(sqliteConnection, sql, -1, &statement, nil)
12921292
defer { sqlite3_finalize(statement) }
@@ -1483,7 +1483,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
14831483
// Now that transaction has begun, we'll rollback in case of error.
14841484
// But we'll throw the first caught error, so that user knows
14851485
// what happened.
1486-
var firstError: Error? = nil
1486+
var firstError: Error?
14871487
let needsRollback: Bool
14881488
do {
14891489
let completion = try operations()
@@ -1626,7 +1626,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
16261626
// Now that savepoint has begun, we'll rollback in case of error.
16271627
// But we'll throw the first caught error, so that user knows
16281628
// what happened.
1629-
var firstError: Error? = nil
1629+
var firstError: Error?
16301630
let needsRollback: Bool
16311631
do {
16321632
let completion = try operations()

GRDB/Core/Statement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public final class Statement {
141141
let authorizer = database.authorizer
142142
authorizer.reset()
143143

144-
var sqliteStatement: SQLiteStatement? = nil
144+
var sqliteStatement: SQLiteStatement?
145145
let code = sqlite3_prepare_v3(
146146
database.sqliteConnection, statementStart, -1, prepFlags,
147147
&sqliteStatement, statementEnd)

GRDB/Core/TransactionObserver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ private struct MetalDatabasePreUpdateEventImpl: DatabasePreUpdateEventImpl {
14941494
sqlite_func: (_ connection: SQLiteConnection, _ column: CInt, _ value: inout SQLiteValue? ) -> CInt)
14951495
-> DatabaseValue?
14961496
{
1497-
var value: SQLiteValue? = nil
1497+
var value: SQLiteValue?
14981498
guard sqlite_func(connection, column, &value) == SQLITE_OK else { return nil }
14991499
if let value {
15001500
return DatabaseValue(sqliteValue: value)

GRDB/FTS/FTS5.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public struct FTS5 {
117117
///
118118
/// Related SQLite documentation: <https://www.sqlite.org/fts5.html#extending_fts5>
119119
public static func api(_ db: Database) -> UnsafePointer<fts5_api> {
120-
var statement: SQLiteStatement? = nil
121-
var api: UnsafePointer<fts5_api>? = nil
120+
var statement: SQLiteStatement?
121+
var api: UnsafePointer<fts5_api>?
122122
let type: StaticString = "fts5_api_ptr"
123123

124124
let code = sqlite3_prepare_v3(db.sqliteConnection, "SELECT fts5(?)", -1, 0, &statement, nil)

GRDB/FTS/FTS5Tokenizer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ extension Database {
208208

209209
self.xTokenizer = xTokenizer
210210

211-
var tokenizerPointer: OpaquePointer? = nil
211+
var tokenizerPointer: OpaquePointer?
212212
let code: CInt
213213
if arguments.isEmpty {
214214
code = xCreate(contextPointer, nil, 0, &tokenizerPointer)

GRDB/QueryInterface/Request/Association/AssociationAggregate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ public struct AssociationAggregate<RowDecoder> {
636636
fileprivate let preparation: AssociationAggregatePreparation<RowDecoder>
637637

638638
/// The SQL name for the value of this aggregate. See forKey(_:).
639-
var key: String? = nil
639+
var key: String?
640640

641641
/// Extends the request with the associated records used to compute the
642642
/// aggregate, and returns the aggregated expression.

GRDB/QueryInterface/SQL/SQLExpression.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ extension SQLExpression {
15921592
case let .associativeBinary(op, expressions):
15931593
assert(expressions.count > 1)
15941594
if op == .and {
1595-
var result: Set<Int64>? = nil
1595+
var result: Set<Int64>?
15961596
for expression in expressions {
15971597
if let expressionRowIDs = try expression.identifyingRowIDs(db, for: alias) {
15981598
if var rowIDs = result {
@@ -2020,8 +2020,8 @@ struct SQLAggregateFunctionInvocation {
20202020
var name: String
20212021
var arguments: [SQLExpression]
20222022
var isDistinct = false
2023-
var ordering: SQLOrdering? = nil // SQLite 3.44.0+
2024-
var filter: SQLExpression? = nil // @available(iOS 14, macOS 10.16, tvOS 14, *) SQLite 3.30+
2023+
var ordering: SQLOrdering? // SQLite 3.44.0+
2024+
var filter: SQLExpression? // @available(iOS 14, macOS 10.16, tvOS 14, *) SQLite 3.30+
20252025

20262026
/// A boolean value indicating if a function is known to return a
20272027
/// JSON value.

0 commit comments

Comments
 (0)