forked from realm/SwiftLint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes MissingDocRuleConfiguration (realm#3713)
* add configuration for missing_docs * fix MissingDocsRuleConfiguration * add to changelog * fix up Config default values and update tests * use XCTAssertTrue and XCTAssertFalse * fix line length violation * finish up unit tests * rever Package.resolved
- Loading branch information
Showing
8 changed files
with
170 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import SwiftLintFramework | ||
import XCTest | ||
|
||
class MissingDocsRuleTests: XCTestCase { | ||
func testWithDefaultConfiguration() { | ||
verifyRule(MissingDocsRule.description) | ||
} | ||
|
||
func testWithExcludesExtensionsDisabled() { | ||
// Perform additional tests with the ignores_comments settings disabled. | ||
let baseDescription = MissingDocsRule.description | ||
let triggeringComments = [ | ||
Example(""" | ||
public extension A {} | ||
""" | ||
) | ||
] | ||
let nonTriggeringExamples = baseDescription.nonTriggeringExamples | ||
.filter { !triggeringComments.contains($0) } | ||
let triggeringExamples = baseDescription.triggeringExamples + triggeringComments | ||
let description = baseDescription | ||
.with(nonTriggeringExamples: nonTriggeringExamples) | ||
.with(triggeringExamples: triggeringExamples) | ||
verifyRule(description, | ||
ruleConfiguration: ["excludes_extensions": false]) | ||
} | ||
|
||
func testWithExcludesInheritedTypesDisabled() { | ||
// Perform additional tests with the ignores_comments settings disabled. | ||
let baseDescription = MissingDocsRule.description | ||
let triggeringComments = [ | ||
// locally-defined superclass member is documented, but subclass member is not | ||
Example(""" | ||
/// docs | ||
public class A { | ||
/// docs | ||
public func b() {} | ||
} | ||
// no docs | ||
public class B: A { override public func b() {} } | ||
"""), | ||
// externally-defined superclass member is documented, but subclass member is not | ||
Example(""" | ||
import Foundation | ||
// no docs | ||
public class B: NSObject { | ||
// no docs | ||
override public var description: String { fatalError() } } | ||
""") | ||
] | ||
let nonTriggeringExamples = baseDescription.nonTriggeringExamples | ||
.filter { !triggeringComments.contains($0) } | ||
let triggeringExamples = baseDescription.triggeringExamples + triggeringComments | ||
let description = baseDescription | ||
.with(nonTriggeringExamples: nonTriggeringExamples) | ||
.with(triggeringExamples: triggeringExamples) | ||
verifyRule(description, | ||
ruleConfiguration: ["excludes_inherited_types": false]) | ||
} | ||
} |