In Xcode Cloud environment, SwiftLint’s cache cannot be written. When using the SwiftLintPlugin, there is no way to disable the cache. Previously, a solution was made for the SwiftLint CLI itself where it looks at a set of environment variables (#4485). This solution offers a cleaner approach where the plugin itself decides whether it needs to enable or disable the cache based on the `CI_XCODE_CLOUD` environment variable.
In the long run, SwiftLint should get rid of `isLikelyXcodeCloudEnvironment` entirely. The caller should always decide if caching is possible or not, while SwiftLint itself should be platform-agnostic.
These aren't enough to enable `-strict-concurrency=complete` for more
modules, but they address some warnings with that flag on and reduces
the scope of what remains to be migrated.
* 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.
* Add CI job to build with strict concurrency
Also include redundant void return clauses for closures in addition to
functions. This can be disabled by configuring the rule with
`include_closures: false`.
Co-authored-by: JP Simard <jp@jpsim.com>
Xcode 15 introduces an additional security check that requires macros to be explicitly enabled:
> Target 'SwiftLintCoreMacros' must be enabled before it can be used.
In CI environments, this is normally not possible. Fortunately, there is a user defaults key to bypass this.