mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Fix spurious Bazel build errors (#5756)
This commit is contained in:
@@ -7,8 +7,6 @@ steps:
|
||||
- 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"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import SwiftSyntax
|
||||
|
||||
@SwiftSyntaxRule
|
||||
struct ArrayInitRule: OptInRule {
|
||||
struct ArrayInitRule: OptInRule, @unchecked Sendable {
|
||||
var configuration = SeverityConfiguration<Self>(.warning)
|
||||
|
||||
static let description = RuleDescription(
|
||||
|
||||
@@ -121,6 +121,20 @@ private extension SwiftLintFile {
|
||||
editorOpen: SourceKittenDictionary,
|
||||
compilerArguments: [String],
|
||||
configuration: UnusedDeclarationConfiguration) -> UnusedDeclarationRule.DeclaredUSR? {
|
||||
// Skip initializers, deinit, enum cases and subscripts since we can't reliably detect if they're used.
|
||||
let declarationKindsToSkip: Set<SwiftDeclarationKind> = [
|
||||
.enumelement,
|
||||
.extensionProtocol,
|
||||
.extension,
|
||||
.extensionEnum,
|
||||
.extensionClass,
|
||||
.extensionStruct,
|
||||
.functionConstructor,
|
||||
.functionDestructor,
|
||||
.functionSubscript,
|
||||
.genericTypeParam,
|
||||
]
|
||||
|
||||
guard let stringKind = indexEntity.kind,
|
||||
stringKind.starts(with: "source.lang.swift.decl."),
|
||||
!stringKind.contains(".accessor."),
|
||||
@@ -196,6 +210,14 @@ private extension SwiftLintFile {
|
||||
}
|
||||
|
||||
private func shouldIgnoreEntity(_ indexEntity: SourceKittenDictionary, relatedUSRsToSkip: Set<String>) -> Bool {
|
||||
let declarationAttributesToSkip: Set<SwiftDeclarationAttributeKind> = [
|
||||
.ibaction,
|
||||
.main,
|
||||
.nsApplicationMain,
|
||||
.override,
|
||||
.uiApplicationMain,
|
||||
]
|
||||
|
||||
if indexEntity.shouldSkipIndexEntityToWorkAroundSR11985() ||
|
||||
indexEntity.shouldSkipRelated(relatedUSRsToSkip: relatedUSRsToSkip) ||
|
||||
indexEntity.enclosedSwiftAttributes.contains(where: declarationAttributesToSkip.contains) ||
|
||||
@@ -321,25 +343,3 @@ private extension SourceKittenDictionary {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Skip initializers, deinit, enum cases and subscripts since we can't reliably detect if they're used.
|
||||
private let declarationKindsToSkip: Set<SwiftDeclarationKind> = [
|
||||
.enumelement,
|
||||
.extensionProtocol,
|
||||
.extension,
|
||||
.extensionEnum,
|
||||
.extensionClass,
|
||||
.extensionStruct,
|
||||
.functionConstructor,
|
||||
.functionDestructor,
|
||||
.functionSubscript,
|
||||
.genericTypeParam,
|
||||
]
|
||||
|
||||
private let declarationAttributesToSkip: Set<SwiftDeclarationAttributeKind> = [
|
||||
.ibaction,
|
||||
.main,
|
||||
.nsApplicationMain,
|
||||
.override,
|
||||
.uiApplicationMain,
|
||||
]
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
files=(
|
||||
"Source/SwiftLintBuiltInRules/Rules/Idiomatic/PrivateOverFilePrivateRule.swift"
|
||||
"Source/SwiftLintBuiltInRules/Rules/Idiomatic/ToggleBoolRule.swift"
|
||||
"Source/SwiftLintBuiltInRules/Rules/Lint/UnusedClosureParameterRule.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
|
||||
Reference in New Issue
Block a user