From 2e012579d8f6cf9ac9c2c7e6964aa9b5f336b4ed Mon Sep 17 00:00:00 2001 From: JP Simard Date: Wed, 1 Nov 2023 09:31:38 -0400 Subject: [PATCH 1/2] Compile with `-strict-concurrency=complete` Only in Bazel for now, because this is considered an unsafe flag in SwiftPM which would lead to warnings for downstream consumers of SwiftLint using SwiftPM. Some imports of SwiftSyntax need the `@preconcurrency` annotation until https://github.com/apple/swift-syntax/pull/2322 is available in a release. The following SwiftLint libraries have `-strict-concurrency=complete` applied: * SwiftLintCoreMacros * SwiftLintBuiltInRules * SwiftLintExtraRules The following SwiftLint libraries don't have the flag applied and need to be migrated: * SwiftLintCore * swiftlint (CLI target) So really the rules and macros are now being compiled with `-strict-concurrency=complete`, but the core infrastructure of SwiftLint is not. Still, given that Swift 6 will eventually make these warnings errors by default, it's good to prevent issues from creeping in earlier rather than later. --- BUILD | 20 ++++++++++++------- .../Idiomatic/DiscouragedNoneNameRule.swift | 2 +- .../Rules/Idiomatic/LegacyRandomRule.swift | 2 +- .../PrivateOverFilePrivateRule.swift | 2 +- .../ShorthandOptionalBindingRule.swift | 2 +- .../Rules/Idiomatic/ToggleBoolRule.swift | 4 ++-- ...DuplicatedKeyInDictionaryLiteralRule.swift | 2 +- .../Rules/Lint/UnusedCaptureListRule.swift | 2 +- .../Lint/UnusedClosureParameterRule.swift | 2 +- .../Rules/Lint/ValidIBInspectableRule.swift | 2 +- .../Rules/Performance/ReduceIntoRule.swift | 2 +- .../Rules/Style/CollectionAlignmentRule.swift | 2 +- .../Rules/Style/DirectReturnRule.swift | 2 +- .../Rules/Style/EmptyEnumArgumentsRule.swift | 2 +- .../NonOverridableClassDeclarationRule.swift | 2 +- .../Style/OptionalEnumCaseMatchingRule.swift | 2 +- .../PreferSelfInStaticReferencesRule.swift | 2 +- .../Style/RedundantSelfInClosureRule.swift | 2 +- .../Rules/Style/SuperfluousElseRule.swift | 2 +- .../Rules/Style/TrailingCommaRule.swift | 2 +- 20 files changed, 33 insertions(+), 27 deletions(-) diff --git a/BUILD b/BUILD index 75f00b2bbe..aecba1a936 100644 --- a/BUILD +++ b/BUILD @@ -11,12 +11,17 @@ copts = [ "ExistentialAny", ] +strict_concurrency_copts = [ + "-Xfrontend", + "-strict-concurrency=complete", +] + # Targets swift_library( name = "SwiftLintCoreMacrosLib", srcs = glob(["Source/SwiftLintCoreMacros/*.swift"]), - copts = copts, + copts = copts + strict_concurrency_copts, module_name = "SwiftLintCoreMacros", visibility = ["//visibility:public"], deps = [ @@ -28,7 +33,7 @@ swift_library( swift_compiler_plugin( name = "SwiftLintCoreMacros", srcs = glob(["Source/SwiftLintCoreMacros/*.swift"]), - copts = copts, + copts = copts + strict_concurrency_copts, deps = [ "@SwiftSyntax//:SwiftCompilerPlugin_opt", "@SwiftSyntax//:SwiftSyntaxMacros_opt", @@ -38,7 +43,7 @@ swift_compiler_plugin( swift_library( name = "SwiftLintCore", srcs = glob(["Source/SwiftLintCore/**/*.swift"]), - copts = copts, + copts = copts, # TODO: strict_concurrency_copts module_name = "SwiftLintCore", plugins = [ ":SwiftLintCoreMacros", @@ -62,7 +67,7 @@ swift_library( swift_library( name = "SwiftLintBuiltInRules", srcs = glob(["Source/SwiftLintBuiltInRules/**/*.swift"]), - copts = copts, + copts = copts + strict_concurrency_copts, module_name = "SwiftLintBuiltInRules", visibility = ["//visibility:public"], deps = [ @@ -76,6 +81,7 @@ swift_library( "Source/SwiftLintExtraRules/Exports.swift", "@swiftlint_extra_rules//:extra_rules", ], + copts = copts + strict_concurrency_copts, module_name = "SwiftLintExtraRules", visibility = ["//visibility:public"], deps = [ @@ -88,7 +94,7 @@ swift_library( srcs = glob( ["Source/SwiftLintFramework/**/*.swift"], ), - copts = copts, + copts = copts + strict_concurrency_copts, module_name = "SwiftLintFramework", visibility = ["//visibility:public"], deps = [ @@ -101,7 +107,7 @@ swift_library( swift_library( name = "swiftlint.library", srcs = glob(["Source/swiftlint/**/*.swift"]), - copts = copts, + copts = copts, # TODO: strict_concurrency_copts module_name = "swiftlint", visibility = ["//visibility:public"], deps = [ @@ -114,7 +120,7 @@ swift_library( swift_binary( name = "swiftlint", - copts = copts, + copts = copts + strict_concurrency_copts, visibility = ["//visibility:public"], deps = [ ":swiftlint.library", diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/DiscouragedNoneNameRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/DiscouragedNoneNameRule.swift index 5a38578b4c..57860059e1 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/DiscouragedNoneNameRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/DiscouragedNoneNameRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct DiscouragedNoneNameRule: OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "discouraged_none_name", name: "Discouraged None Name", description: "Enum cases and static members named `none` are discouraged as they can conflict with " + diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/LegacyRandomRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/LegacyRandomRule.swift index 261462c527..5b0686589b 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/LegacyRandomRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/LegacyRandomRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct LegacyRandomRule: Rule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "legacy_random", name: "Legacy Random", description: "Prefer using `type.random(in:)` over legacy functions", diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift index 8ad50f51eb..c501bfb713 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift @@ -1,4 +1,4 @@ -import SwiftSyntax +@preconcurrency import SwiftSyntax @SwiftSyntaxRule struct PrivateOverFilePrivateRule: SwiftSyntaxCorrectableRule { diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ShorthandOptionalBindingRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ShorthandOptionalBindingRule.swift index 203a993c67..ed50d0beba 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ShorthandOptionalBindingRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ShorthandOptionalBindingRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct ShorthandOptionalBindingRule: OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "shorthand_optional_binding", name: "Shorthand Optional Binding", description: "Use shorthand syntax for optional binding", diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift index cc1435a1a3..ea4a984817 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift @@ -1,11 +1,11 @@ -import SwiftSyntax +@preconcurrency import SwiftSyntax import SwiftSyntaxBuilder @SwiftSyntaxRule(explicitRewriter: true) struct ToggleBoolRule: OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "toggle_bool", name: "Toggle Bool", description: "Prefer `someBool.toggle()` over `someBool = !someBool`", diff --git a/Source/SwiftLintBuiltInRules/Rules/Lint/DuplicatedKeyInDictionaryLiteralRule.swift b/Source/SwiftLintBuiltInRules/Rules/Lint/DuplicatedKeyInDictionaryLiteralRule.swift index bd0480e0c7..48ff81fd12 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Lint/DuplicatedKeyInDictionaryLiteralRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Lint/DuplicatedKeyInDictionaryLiteralRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct DuplicatedKeyInDictionaryLiteralRule: Rule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "duplicated_key_in_dictionary_literal", name: "Duplicated Key in Dictionary Literal", description: "Dictionary literals with duplicated keys will crash at runtime", diff --git a/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedCaptureListRule.swift b/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedCaptureListRule.swift index f42a6d9e24..17f0fb617d 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedCaptureListRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedCaptureListRule.swift @@ -12,7 +12,7 @@ private func warnDeprecatedOnce() { struct UnusedCaptureListRule: SwiftSyntaxRule, OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "unused_capture_list", name: "Unused Capture List", description: "Unused reference in a capture list should be removed", diff --git a/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedClosureParameterRule.swift b/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedClosureParameterRule.swift index 97a8145eec..26523c241e 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedClosureParameterRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Lint/UnusedClosureParameterRule.swift @@ -1,4 +1,4 @@ -import SwiftSyntax +@preconcurrency import SwiftSyntax import SwiftSyntaxBuilder @SwiftSyntaxRule(explicitRewriter: true) diff --git a/Source/SwiftLintBuiltInRules/Rules/Lint/ValidIBInspectableRule.swift b/Source/SwiftLintBuiltInRules/Rules/Lint/ValidIBInspectableRule.swift index 7cab2dbf39..7ded48d717 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Lint/ValidIBInspectableRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Lint/ValidIBInspectableRule.swift @@ -109,7 +109,7 @@ struct ValidIBInspectableRule: Rule { ] ) - fileprivate static var supportedTypes: Set = { + fileprivate static let supportedTypes: Set = { // "You can add the IBInspectable attribute to any property in a class declaration, // class extension, or category of type: boolean, integer or floating point number, string, // localized string, rectangle, point, size, color, range, and nil." diff --git a/Source/SwiftLintBuiltInRules/Rules/Performance/ReduceIntoRule.swift b/Source/SwiftLintBuiltInRules/Rules/Performance/ReduceIntoRule.swift index 0c8e8a54ec..e7269ea5a1 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Performance/ReduceIntoRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Performance/ReduceIntoRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct ReduceIntoRule: OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "reduce_into", name: "Reduce into", description: "Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/CollectionAlignmentRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/CollectionAlignmentRule.swift index 6d6e946cc6..3d34029eb2 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/CollectionAlignmentRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/CollectionAlignmentRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct CollectionAlignmentRule: OptInRule { var configuration = CollectionAlignmentConfiguration() - static var description = RuleDescription( + static let description = RuleDescription( identifier: "collection_alignment", name: "Collection Element Alignment", description: "All elements in a collection literal should be vertically aligned", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/DirectReturnRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/DirectReturnRule.swift index c486deb4ec..9a730fbfd4 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/DirectReturnRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/DirectReturnRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct DirectReturnRule: OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "direct_return", name: "Direct Return", description: "Directly return the expression instead of assigning it to a variable first", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift index 1daae7ad0e..9bc35f8ff8 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift @@ -1,4 +1,4 @@ -import SwiftSyntax +@preconcurrency import SwiftSyntax private func wrapInSwitch( variable: String = "foo", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/NonOverridableClassDeclarationRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/NonOverridableClassDeclarationRule.swift index d841e7e652..fa407544c9 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/NonOverridableClassDeclarationRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/NonOverridableClassDeclarationRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct NonOverridableClassDeclarationRule: SwiftSyntaxCorrectableRule, OptInRule { var configuration = NonOverridableClassDeclarationConfiguration() - static var description = RuleDescription( + static let description = RuleDescription( identifier: "non_overridable_class_declaration", name: "Class Declaration in Final Class", description: """ diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift index 377bceeaa8..4a962d432a 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift @@ -1,4 +1,4 @@ -import SwiftSyntax +@preconcurrency import SwiftSyntax @SwiftSyntaxRule(explicitRewriter: true) struct OptionalEnumCaseMatchingRule: OptInRule { diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/PreferSelfInStaticReferencesRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/PreferSelfInStaticReferencesRule.swift index 2554a4a0d0..6484f83d3b 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/PreferSelfInStaticReferencesRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/PreferSelfInStaticReferencesRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct PreferSelfInStaticReferencesRule: SwiftSyntaxCorrectableRule, OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "prefer_self_in_static_references", name: "Prefer Self in Static References", description: "Use `Self` to refer to the surrounding type name", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/RedundantSelfInClosureRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/RedundantSelfInClosureRule.swift index b4267fd133..6d37360be1 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/RedundantSelfInClosureRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/RedundantSelfInClosureRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct RedundantSelfInClosureRule: SwiftSyntaxCorrectableRule, OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "redundant_self_in_closure", name: "Redundant Self in Closure", description: "Explicit use of 'self' is not required", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/SuperfluousElseRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/SuperfluousElseRule.swift index de7353aca1..ac090a818a 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/SuperfluousElseRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/SuperfluousElseRule.swift @@ -4,7 +4,7 @@ import SwiftSyntax struct SuperfluousElseRule: OptInRule { var configuration = SeverityConfiguration(.warning) - static var description = RuleDescription( + static let description = RuleDescription( identifier: "superfluous_else", name: "Superfluous Else", description: "Else branches should be avoided when the previous if-block exits the current scope", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift index 0861c34afd..365916b053 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift @@ -1,4 +1,4 @@ -import SwiftSyntax +@preconcurrency import SwiftSyntax @SwiftSyntaxRule struct TrailingCommaRule: SwiftSyntaxCorrectableRule { From 7a1846702857ae110197c78d46431fd23bfa7042 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Wed, 1 Nov 2023 10:58:16 -0400 Subject: [PATCH 2/2] Add CI job to build with strict concurrency --- .buildkite/pipeline.yml | 8 ++++++++ BUILD | 10 +++++++++- .../Idiomatic/PrivateOverFilePrivateRule.swift | 2 +- .../Rules/Idiomatic/ToggleBoolRule.swift | 4 ++-- .../Rules/Style/EmptyEnumArgumentsRule.swift | 2 +- .../Rules/Style/OptionalEnumCaseMatchingRule.swift | 2 +- .../Rules/Style/TrailingCommaRule.swift | 2 +- tools/add-preconcurrency-imports.sh | 13 +++++++++++++ 8 files changed, 36 insertions(+), 7 deletions(-) create mode 100755 tools/add-preconcurrency-imports.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 210cbb5915..cd9ba72a07 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,6 +5,14 @@ steps: - bazel build :swiftlint - echo "+++ Test" - bazel test --test_output=errors //Tests/... + - label: "Build With Strict Concurrency" + commands: + - echo "+++ Add @preconcurrency imports" + - ./tools/add-preconcurrency-imports.sh + - echo "+++ Build" + - bazel build --define strict_concurrency_builtin_rules=true :swiftlint + - echo "--- Clean up" + - git reset --hard - label: "SwiftPM" commands: - echo "+++ Test" diff --git a/BUILD b/BUILD index aecba1a936..c2ca64d5f1 100644 --- a/BUILD +++ b/BUILD @@ -6,6 +6,11 @@ load( "swift_library", ) +config_setting( + name = "strict_concurrency_builtin_rules", + values = {"define": "strict_concurrency_builtin_rules=true"}, +) + copts = [ "-enable-upcoming-feature", "ExistentialAny", @@ -67,7 +72,10 @@ swift_library( swift_library( name = "SwiftLintBuiltInRules", srcs = glob(["Source/SwiftLintBuiltInRules/**/*.swift"]), - copts = copts + strict_concurrency_copts, + copts = copts + select({ + ":strict_concurrency_builtin_rules": strict_concurrency_copts, + "//conditions:default": [], + }), module_name = "SwiftLintBuiltInRules", visibility = ["//visibility:public"], deps = [ diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift index c501bfb713..8ad50f51eb 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift @@ -1,4 +1,4 @@ -@preconcurrency import SwiftSyntax +import SwiftSyntax @SwiftSyntaxRule struct PrivateOverFilePrivateRule: SwiftSyntaxCorrectableRule { diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift index ea4a984817..cc1435a1a3 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift @@ -1,11 +1,11 @@ -@preconcurrency import SwiftSyntax +import SwiftSyntax import SwiftSyntaxBuilder @SwiftSyntaxRule(explicitRewriter: true) struct ToggleBoolRule: OptInRule { var configuration = SeverityConfiguration(.warning) - static let description = RuleDescription( + static var description = RuleDescription( identifier: "toggle_bool", name: "Toggle Bool", description: "Prefer `someBool.toggle()` over `someBool = !someBool`", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift index 9bc35f8ff8..1daae7ad0e 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift @@ -1,4 +1,4 @@ -@preconcurrency import SwiftSyntax +import SwiftSyntax private func wrapInSwitch( variable: String = "foo", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift index 4a962d432a..377bceeaa8 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift @@ -1,4 +1,4 @@ -@preconcurrency import SwiftSyntax +import SwiftSyntax @SwiftSyntaxRule(explicitRewriter: true) struct OptionalEnumCaseMatchingRule: OptInRule { diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift index 365916b053..0861c34afd 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift @@ -1,4 +1,4 @@ -@preconcurrency import SwiftSyntax +import SwiftSyntax @SwiftSyntaxRule struct TrailingCommaRule: SwiftSyntaxCorrectableRule { diff --git a/tools/add-preconcurrency-imports.sh b/tools/add-preconcurrency-imports.sh new file mode 100755 index 0000000000..acef5af261 --- /dev/null +++ b/tools/add-preconcurrency-imports.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +files=( +"Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift" +"Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift" +"Source/SwiftLintBuiltInRules/Rules/Style/EmptyEnumArgumentsRule.swift" +"Source/SwiftLintBuiltInRules/Rules/Style/OptionalEnumCaseMatchingRule.swift" +"Source/SwiftLintBuiltInRules/Rules/Style/TrailingCommaRule.swift" +) + +for file in "${files[@]}"; do + sed -i '' -e 's/import SwiftSyntax$/@preconcurrency import SwiftSyntax/g' "$file" +done