Skip to content

Commit 06f76a9

Browse files
authored
minor: update linting tools versions (#49)
Update SwiftFormat to 0.47.3 and SwiftLint to 0.41.0 to match the driver
1 parent a38a34d commit 06f76a9

File tree

11 files changed

+38
-29
lines changed

11 files changed

+38
-29
lines changed

.evergreen/install-tools.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ swiftenv local $SWIFT_VERSION
3939

4040
if [ $1 == "swiftlint" ]
4141
then
42-
build_from_gh swiftlint https://github.com/realm/SwiftLint "0.40.0"
42+
build_from_gh swiftlint https://github.com/realm/SwiftLint "0.41.0"
4343
elif [ $1 == "swiftformat" ]
4444
then
45-
build_from_gh swiftformat https://github.com/nicklockwood/SwiftFormat "0.44.13"
45+
build_from_gh swiftformat https://github.com/nicklockwood/SwiftFormat "0.47.3"
4646
elif [ $1 == "sourcery" ]
4747
then
4848
install_from_gh sourcery https://github.com/krzysztofzablocki/Sourcery/releases/download/0.18.0/Sourcery-0.18.0.zip

.swiftformat

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
--exclude .build/*,opt/*
2+
--exclude etc
23

34
# unnecessary
45
--disable andOperator
@@ -10,7 +11,7 @@
1011
--indent 4
1112

1213
# 0..<3 vs 0 ..< 3
13-
--nospaceoperators "..<","..."
14+
--nospaceoperators ...,..<
1415

1516
# always want explicit acl
1617
--disable redundantExtensionACL
@@ -35,5 +36,8 @@
3536
# the ordering doesn't match linter's
3637
--disable specifiers
3738

38-
# Temporary while library is implemented
39-
--disable unusedArguments
39+
# conflicts with our Swiftlint explicit ACL rule
40+
--disable extensionAccessControl
41+
42+
# creates non-compiling code on Swift 5.1
43+
--disable preferKeyPath

.swiftlint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ disabled_rules:
55
- todo
66
- type_body_length
77
- type_name
8+
- inclusive_language # disabled until we complete work for the "remove offensive terminology" project.
89
- cyclomatic_complexity
10+
- opening_brace # conflicts with SwiftFormat wrapMultilineStatementBraces
911

1012
opt_in_rules:
1113
- array_init

Sources/SwiftBSON/BSONDecimal128.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ public struct BSONDecimal128: Equatable, Hashable, CustomStringConvertible {
226226

227227
let decimalPartNSRange = match.range(at: REGroups.decimalPart.rawValue)
228228
guard decimalPartNSRange.location != NSNotFound,
229-
let decimalPartRange = Range(decimalPartNSRange, in: data) else {
229+
let decimalPartRange = Range(decimalPartNSRange, in: data)
230+
else {
230231
throw BSONError.InvalidArgumentError(
231232
message: "Syntax Error: \(data) Missing digits in front of the exponent"
232233
)

Sources/SwiftBSON/BSONDecoder.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ private struct _BSONUnkeyedDecodingContainer: UnkeyedDecodingContainer {
800800

801801
/// Decodes a nested container keyed by the given type.
802802
public mutating func nestedContainer<NestedKey: CodingKey>(keyedBy _: NestedKey.Type)
803-
throws -> KeyedDecodingContainer<NestedKey> {
803+
throws -> KeyedDecodingContainer<NestedKey>
804+
{
804805
try self.decoder.with(pushedKey: _BSONKey(index: self.currentIndex)) {
805806
try self.checkAtEnd()
806807
let doc = try self.decodeBSONType(BSONDocument.self)

Sources/SwiftBSON/BSONEncoder.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,8 @@ private struct _BSONUnkeyedEncodingContainer: UnkeyedEncodingContainer {
676676
}
677677

678678
public mutating func nestedContainer<NestedKey>(keyedBy _: NestedKey.Type)
679-
-> KeyedEncodingContainer<NestedKey> {
679+
-> KeyedEncodingContainer<NestedKey>
680+
{
680681
self.codingPath.append(_BSONKey(index: self.count))
681682
defer { self.codingPath.removeLast() }
682683

@@ -769,7 +770,7 @@ private class MutableArray: BSONValue {
769770

770771
fileprivate init() {}
771772

772-
internal required init(fromExtJSON json: JSON, keyPath: [String]) throws {
773+
internal required init(fromExtJSON _: JSON, keyPath _: [String]) throws {
773774
fatalError("MutableArray: BSONValue.init(fromExtJSON) should be unused")
774775
}
775776

@@ -783,11 +784,11 @@ private class MutableArray: BSONValue {
783784

784785
/// methods required by the BSONValue protocol that we don't actually need/use. MutableArray
785786
/// is just a BSONValue to simplify usage alongside true BSONValues within the encoder.
786-
static func read(from buffer: inout ByteBuffer) throws -> BSON {
787+
static func read(from _: inout ByteBuffer) throws -> BSON {
787788
fatalError("MutableArray is not meant to be read from a ByteBuffer")
788789
}
789790

790-
func write(to buffer: inout ByteBuffer) {
791+
func write(to _: inout ByteBuffer) {
791792
fatalError("MutableArray is not meant to be written to a ByteBuffer")
792793
}
793794

@@ -865,7 +866,7 @@ private class MutableDictionary: BSONValue {
865866

866867
fileprivate init() {}
867868

868-
internal required init?(fromExtJSON json: JSON, keyPath: [String]) throws {
869+
internal required init?(fromExtJSON _: JSON, keyPath _: [String]) throws {
869870
fatalError("MutableDictionary: BSONValue.init(fromExtJSON) should be unused")
870871
}
871872

@@ -879,11 +880,11 @@ private class MutableDictionary: BSONValue {
879880

880881
/// methods required by the BSONValue protocol that we don't actually need/use. MutableDictionary
881882
/// is just a BSONValue to simplify usage alongside true BSONValues within the encoder.
882-
static func read(from buffer: inout ByteBuffer) throws -> BSON {
883+
static func read(from _: inout ByteBuffer) throws -> BSON {
883884
fatalError("MutableDictionary is not meant to be read from a ByteBuffer")
884885
}
885886

886-
func write(to buffer: inout ByteBuffer) {
887+
func write(to _: inout ByteBuffer) {
887888
fatalError("MutableDictionary is not meant to be encoded to a ByteBuffer")
888889
}
889890

Sources/SwiftBSON/BSONNulls.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal struct BSONNull: BSONValue, Equatable {
1414
* - `nil` if the provided value is not `null`.
1515
*
1616
*/
17-
internal init?(fromExtJSON json: JSON, keyPath: [String]) {
17+
internal init?(fromExtJSON json: JSON, keyPath _: [String]) {
1818
switch json {
1919
case .null:
2020
// canonical or relaxed extended JSON
@@ -41,11 +41,11 @@ internal struct BSONNull: BSONValue, Equatable {
4141
/// Initializes a new `BSONNull` instance.
4242
internal init() {}
4343

44-
internal static func read(from: inout ByteBuffer) throws -> BSON {
44+
internal static func read(from _: inout ByteBuffer) throws -> BSON {
4545
.null
4646
}
4747

48-
internal func write(to: inout ByteBuffer) {
48+
internal func write(to _: inout ByteBuffer) {
4949
// no-op
5050
}
5151
}
@@ -97,11 +97,11 @@ internal struct BSONUndefined: BSONValue, Equatable {
9797
/// Initializes a new `BSONUndefined` instance.
9898
internal init() {}
9999

100-
internal static func read(from: inout ByteBuffer) throws -> BSON {
100+
internal static func read(from _: inout ByteBuffer) throws -> BSON {
101101
.undefined
102102
}
103103

104-
internal func write(to: inout ByteBuffer) {
104+
internal func write(to _: inout ByteBuffer) {
105105
// no-op
106106
}
107107
}
@@ -153,11 +153,11 @@ internal struct BSONMinKey: BSONValue, Equatable {
153153
/// Initializes a new `MinKey` instance.
154154
internal init() {}
155155

156-
internal static func read(from: inout ByteBuffer) throws -> BSON {
156+
internal static func read(from _: inout ByteBuffer) throws -> BSON {
157157
.minKey
158158
}
159159

160-
internal func write(to: inout ByteBuffer) {
160+
internal func write(to _: inout ByteBuffer) {
161161
// no-op
162162
}
163163
}
@@ -209,11 +209,11 @@ internal struct BSONMaxKey: BSONValue, Equatable {
209209
/// Initializes a new `MaxKey` instance.
210210
internal init() {}
211211

212-
internal static func read(from: inout ByteBuffer) throws -> BSON {
212+
internal static func read(from _: inout ByteBuffer) throws -> BSON {
213213
.maxKey
214214
}
215215

216-
internal func write(to: inout ByteBuffer) {
216+
internal func write(to _: inout ByteBuffer) {
217217
// no-op
218218
}
219219
}

Sources/SwiftBSON/Bool+BSONValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extension Bool: BSONValue {
1212
* Returns:
1313
* - `nil` if the provided value is not a `Bool`.
1414
*/
15-
internal init?(fromExtJSON json: JSON, keyPath: [String]) {
15+
internal init?(fromExtJSON json: JSON, keyPath _: [String]) {
1616
switch json {
1717
case let .bool(b):
1818
// canonical or relaxed extended JSON

Sources/SwiftBSON/ExtendedJSONDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ExtendedJSONDecoder {
2727
/// - data: `Data` which represents the JSON that will be decoded.
2828
/// - Returns: Decoded representation of the JSON input as an instance of `T`.
2929
/// - Throws: `DecodingError` if the JSON data is corrupt or if any value throws an error during decoding.
30-
public func decode<T: Decodable>(_ type: T.Type, from data: Data) throws -> T {
30+
public func decode<T: Decodable>(_: T.Type, from data: Data) throws -> T {
3131
// Data --> JSON --> BSON --> T
3232
// Takes in JSON as `Data` encoded with `.utf8` and runs it through a `JSONDecoder` to get an
3333
// instance of the `JSON` enum.

Sources/SwiftBSON/String+BSONValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extension String: BSONValue {
1212
* Returns:
1313
* - `nil` if the provided value is not an `String`.
1414
*/
15-
internal init?(fromExtJSON json: JSON, keyPath: [String]) {
15+
internal init?(fromExtJSON json: JSON, keyPath _: [String]) {
1616
switch json {
1717
case let .string(s):
1818
self = s

0 commit comments

Comments
 (0)