Skip to content

Commit 5986f65

Browse files
authored
Merge pull request swiftlang#227 from dylansturg/more_optional_rules
Migrate some rules to opt-in status.
2 parents 8ef3b43 + dc3eccb commit 5986f65

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Sources/SwiftFormatConfiguration/RuleRegistry+Generated.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum RuleRegistry {
3232
"NoCasesWithOnlyFallthrough": true,
3333
"NoEmptyTrailingClosureParentheses": true,
3434
"NoLabelsInCasePatterns": true,
35-
"NoLeadingUnderscores": true,
35+
"NoLeadingUnderscores": false,
3636
"NoParensAroundConditions": true,
3737
"NoVoidReturnOnFunctionSignature": true,
3838
"OneCasePerLine": true,
@@ -45,6 +45,6 @@ enum RuleRegistry {
4545
"UseSingleLinePropertyGetter": true,
4646
"UseSynthesizedInitializer": true,
4747
"UseTripleSlashForDocumentationComments": true,
48-
"ValidateDocumentationComments": true,
48+
"ValidateDocumentationComments": false,
4949
]
5050
}

Sources/SwiftFormatRules/NoLeadingUnderscores.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import SwiftSyntax
2525
/// Lint: Declaring an identifier with a leading underscore yields a lint error.
2626
public final class NoLeadingUnderscores: SyntaxLintRule {
2727

28+
/// Identifies this rule as being opt-in. While leading underscores aren't meant to be used in
29+
/// normal circumstances, there are situations where they can be used to hint which APIs should be
30+
/// avoided by general users. In particular when APIs must be exported publicly, but the author
31+
/// doesn't intend for arbitrary usage.
32+
public override class var isOptIn: Bool { return true }
33+
2834
public override func visit(_ node: AssociatedtypeDeclSyntax) -> SyntaxVisitorContinueKind {
2935
diagnoseIfNameStartsWithUnderscore(node.identifier)
3036
return .visitChildren

Sources/SwiftFormatRules/ValidateDocumentationComments.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import SwiftSyntax
2222
/// invalid (uses `Parameters` when there is only one parameter) will yield a lint error.
2323
public final class ValidateDocumentationComments: SyntaxLintRule {
2424

25+
/// Identifies this rule as being opt-in. Accurate and complete documentation comments are
26+
/// important, but this rule isn't able to handle situations where portions of documentation are
27+
/// redundant. For example when the returns clause is redundant for a simple declaration.
28+
public override class var isOptIn: Bool { return true }
29+
2530
public override func visit(_ node: InitializerDeclSyntax) -> SyntaxVisitorContinueKind {
2631
return checkFunctionLikeDocumentation(
2732
DeclSyntax(node), name: "init", parameters: node.parameters.parameterList, throwsOrRethrowsKeyword: node.throwsOrRethrowsKeyword)

0 commit comments

Comments
 (0)