diff --git a/.swiftlint.yml b/.swiftlint.yml index 8d99afc..31908d3 100755 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -38,6 +38,12 @@ file_header: \/\/ custom_rules: + class_semantics: + included: ".*.swift" + regex: '^(?!.*(final|abstract|recursive)).*class [A-Z]+.*\{' + name: "Class Semantics Specification" + message: "Specify the class semantics with either final, /* abstract */ or /* recursive */ keywords. Recursive means that class is used both itself & as a superclass." + severity: warning closing_brace_whitespace: included: ".*.swift" regex: '(?:\n| {2,})\}\)? *\n *[^ \n\})\]]' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1052b02..918b885 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,6 +33,7 @@ Please obey these guidelines: - Write expressive tests covering any edited / newly created code. - Within the `Collections`, `Helpers` and `Tests/Sources` folders, sort things alphabetically. - For **file headers** in Swift source files, use the following format: + ```swift // // [File Title].swift diff --git a/Helpers/Weak.swift b/Helpers/Weak.swift index 5d73026..40eb03d 100644 --- a/Helpers/Weak.swift +++ b/Helpers/Weak.swift @@ -9,7 +9,7 @@ import Foundation /// Weak wrapper for generic AnyObject. -class Weak: Hashable where T: AnyObject { +final class Weak: Hashable where T: AnyObject { // MARK: - Properties let hashValue: Int private(set) weak var value: T? diff --git a/Tests/Sources/BagTests.swift b/Tests/Sources/BagTests.swift index 98202cd..d78cc10 100644 --- a/Tests/Sources/BagTests.swift +++ b/Tests/Sources/BagTests.swift @@ -9,7 +9,7 @@ @testable import SwiftCollections import XCTest -class BagTests: XCTestCase { +final class BagTests: XCTestCase { // MARK: - Properties private lazy var baseBag: Bag = { // Assuming array init works properly diff --git a/Tests/Sources/WeakArrayTests.swift b/Tests/Sources/WeakArrayTests.swift index cc9154c..b367569 100644 --- a/Tests/Sources/WeakArrayTests.swift +++ b/Tests/Sources/WeakArrayTests.swift @@ -9,9 +9,9 @@ @testable import SwiftCollections import XCTest -class WeakArrayTests: XCTestCase { +final class WeakArrayTests: XCTestCase { // MARK: - Subtypes - class SampleObject { } + final class SampleObject { } // MARK: - Properties private let arraySize = 3 diff --git a/Tests/Sources/WeakDictionaryTests.swift b/Tests/Sources/WeakDictionaryTests.swift index af29213..6875b2f 100644 --- a/Tests/Sources/WeakDictionaryTests.swift +++ b/Tests/Sources/WeakDictionaryTests.swift @@ -11,9 +11,9 @@ import Foundation @testable import SwiftCollections import XCTest -class WeakDictionaryTests: XCTestCase { +final class WeakDictionaryTests: XCTestCase { // MARK: - Subtypes - class SampleObject: Hashable { + final class SampleObject: Hashable { var hashValue: Int init(_ hashValue: Int) { diff --git a/Tests/Sources/WeakSetTests.swift b/Tests/Sources/WeakSetTests.swift index e3414ba..efbddd9 100644 --- a/Tests/Sources/WeakSetTests.swift +++ b/Tests/Sources/WeakSetTests.swift @@ -9,9 +9,9 @@ @testable import SwiftCollections import XCTest -class WeakSetTests: XCTestCase { +final class WeakSetTests: XCTestCase { // MARK: - Subtypes - class SampleObject: Hashable { + final class SampleObject: Hashable { var hashValue: Int init(_ hashValue: Int) {