Maintain SourceKit-mode as long as custom rules don't support SwiftSyntax (#6212)

This commit is contained in:
Danny Mösch
2025-08-30 09:42:52 +02:00
committed by GitHub
parent 8ada387884
commit 7624586c18
2 changed files with 8 additions and 8 deletions
@@ -75,7 +75,7 @@ struct CustomRules: Rule, CacheDescriptionProvider, ConditionallySourceKitFree {
var isEffectivelySourceKitFree: Bool {
configuration.customRuleConfigurations.allSatisfy { config in
let effectiveMode = config.executionMode == .default
? (configuration.defaultExecutionMode ?? .swiftsyntax)
? (configuration.defaultExecutionMode ?? .sourcekit)
: config.executionMode
return effectiveMode == .swiftsyntax
}
+7 -7
View File
@@ -685,7 +685,7 @@ final class CustomRulesTests: SwiftLintTestCase {
XCTAssertEqual(violations[1].location.character, 18)
}
func testCustomRuleDefaultsToSwiftSyntaxWhenNoModeSpecified() throws {
func testCustomRuleDefaultsToSourceKitWhenNoModeSpecified() throws {
// When NO execution mode is specified (neither default nor per-rule), it should default to swiftsyntax
let customRules: [String: Any] = [
"no_foo": [
@@ -713,8 +713,8 @@ final class CustomRulesTests: SwiftLintTestCase {
return
}
XCTAssertTrue(customRule.isEffectivelySourceKitFree,
"Rule should be effectively SourceKit-free when defaulting to swiftsyntax")
XCTAssertFalse(customRule.isEffectivelySourceKitFree,
"Rule depends on SourceKit")
}
func testCustomRuleWithMatchKindsUsesSwiftSyntaxWhenConfigured() throws {
@@ -740,8 +740,8 @@ final class CustomRulesTests: SwiftLintTestCase {
XCTAssertEqual(violations[0].location.character, 23) // Position of 'foo' in comment
}
func testCustomRuleWithKindFilteringDefaultsToSwiftSyntax() throws {
// When using kind filtering without specifying mode, it should default to swiftsyntax
func testCustomRuleWithKindFilteringDefaultsToSourceKit() throws {
// When using kind filtering without specifying mode, it should default to sourcekit
let customRules: [String: Any] = [
"no_keywords": [
"regex": "\\b\\w+\\b",
@@ -769,8 +769,8 @@ final class CustomRulesTests: SwiftLintTestCase {
return
}
XCTAssertTrue(customRule.isEffectivelySourceKitFree,
"Rule with kind filtering should default to swiftsyntax mode")
XCTAssertFalse(customRule.isEffectivelySourceKitFree,
"Rule with kind filtering should default to sourcekit mode")
}
func testCustomRuleWithExcludedMatchKindsUsesSwiftSyntaxWithDefaultMode() throws {