Skip to content

Commit 9acae82

Browse files
committed
Delete unsafe UseEnumsForNamespacing rule
While using enums for namespaces is a superior coding practice, this rule lacks sufficient context to safely perform this transformation. It's possible to use extensions in the same file or a different file to add a conformance to a struct which makes it ineligible to become an enum. Unfortunately, the SyntaxVisitor is only able to look at nodes in the AST for a single file and that is too narrow of a scope to verify that the struct can safely be an enum. Even as a lint rule, this would raise false positives and those false positives cannot be removed. It's best not to convert to a lint rule for that reason.
1 parent 6e521cd commit 9acae82

File tree

5 files changed

+0
-352
lines changed

5 files changed

+0
-352
lines changed

Sources/SwiftFormat/Pipelines+Generated.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ class LintPipeline: SyntaxVisitor {
225225
visitIfEnabled(BeginDocumentationCommentWithOneLineSummary.visit, in: context, for: node)
226226
visitIfEnabled(DontRepeatTypeInStaticProperties.visit, in: context, for: node)
227227
visitIfEnabled(NoLeadingUnderscores.visit, in: context, for: node)
228-
visitIfEnabled(UseEnumForNamespacing.visit, in: context, for: node)
229228
visitIfEnabled(UseSynthesizedInitializer.visit, in: context, for: node)
230229
visitIfEnabled(UseTripleSlashForDocumentationComments.visit, in: context, for: node)
231230
return .visitChildren
@@ -300,7 +299,6 @@ extension FormatPipeline {
300299
node = OneVariableDeclarationPerLine(context: context).visit(node)
301300
node = OrderedImports(context: context).visit(node)
302301
node = ReturnVoidInsteadOfEmptyTuple(context: context).visit(node)
303-
node = UseEnumForNamespacing(context: context).visit(node)
304302
node = UseShorthandTypeNames(context: context).visit(node)
305303
node = UseSingleLinePropertyGetter(context: context).visit(node)
306304
node = UseTripleSlashForDocumentationComments(context: context).visit(node)

Sources/SwiftFormatConfiguration/RuleRegistry+Generated.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ enum RuleRegistry {
4040
"OnlyOneTrailingClosureArgument": true,
4141
"OrderedImports": true,
4242
"ReturnVoidInsteadOfEmptyTuple": true,
43-
"UseEnumForNamespacing": true,
4443
"UseLetInEveryBoundCaseVariable": true,
4544
"UseShorthandTypeNames": true,
4645
"UseSingleLinePropertyGetter": true,

Sources/SwiftFormatRules/UseEnumForNamespacing.swift

Lines changed: 0 additions & 114 deletions
This file was deleted.

Tests/SwiftFormatRulesTests/UseEnumForNamespacingTests.swift

Lines changed: 0 additions & 224 deletions
This file was deleted.

Tests/SwiftFormatRulesTests/XCTestManifests.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,6 @@ extension UseEarlyExitsTests {
299299
]
300300
}
301301

302-
extension UseEnumForNamespacingTests {
303-
// DO NOT MODIFY: This is autogenerated, use:
304-
// `swift test --generate-linuxmain`
305-
// to regenerate.
306-
static let __allTests__UseEnumForNamespacingTests = [
307-
("testNestedEnumsForNameSpaces", testNestedEnumsForNameSpaces),
308-
("testNonEnumsUsedAsNamespaces", testNonEnumsUsedAsNamespaces),
309-
]
310-
}
311-
312302
extension UseLetInEveryBoundCaseVariableTests {
313303
// DO NOT MODIFY: This is autogenerated, use:
314304
// `swift test --generate-linuxmain`
@@ -428,7 +418,6 @@ public func __allTests() -> [XCTestCaseEntry] {
428418
testCase(OrderedImportsTests.__allTests__OrderedImportsTests),
429419
testCase(ReturnVoidInsteadOfEmptyTupleTests.__allTests__ReturnVoidInsteadOfEmptyTupleTests),
430420
testCase(UseEarlyExitsTests.__allTests__UseEarlyExitsTests),
431-
testCase(UseEnumForNamespacingTests.__allTests__UseEnumForNamespacingTests),
432421
testCase(UseLetInEveryBoundCaseVariableTests.__allTests__UseLetInEveryBoundCaseVariableTests),
433422
testCase(UseShorthandTypeNamesTests.__allTests__UseShorthandTypeNamesTests),
434423
testCase(UseSingleLinePropertyGetterTests.__allTests__UseSingleLinePropertyGetterTests),

0 commit comments

Comments
 (0)