Skip to content

Commit

Permalink
Add class_semantics SwiftLint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
fredpi committed May 2, 2018
1 parent 7cdc6a8 commit 7d9a502
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .swiftlint.yml
Expand Up @@ -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\})\]]'
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Helpers/Weak.swift
Expand Up @@ -9,7 +9,7 @@
import Foundation

/// Weak wrapper for generic AnyObject.
class Weak<T>: Hashable where T: AnyObject {
final class Weak<T>: Hashable where T: AnyObject {
// MARK: - Properties
let hashValue: Int
private(set) weak var value: T?
Expand Down
2 changes: 1 addition & 1 deletion Tests/Sources/BagTests.swift
Expand Up @@ -9,7 +9,7 @@
@testable import SwiftCollections
import XCTest

class BagTests: XCTestCase {
final class BagTests: XCTestCase {
// MARK: - Properties
private lazy var baseBag: Bag<Int> = {
// Assuming array init works properly
Expand Down
4 changes: 2 additions & 2 deletions Tests/Sources/WeakArrayTests.swift
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Tests/Sources/WeakDictionaryTests.swift
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Sources/WeakSetTests.swift
Expand Up @@ -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) {
Expand Down

0 comments on commit 7d9a502

Please sign in to comment.