Skip to content

Commit 1d83385

Browse files
committed
Fix possible concurrent mutation crash
1 parent c04f702 commit 1d83385

14 files changed

+130
-151
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
swift_package_resolve: swift package resolve
1010
swift_build: swift build
1111
swift_test: swift test
12-
periphery_scan: ./.build/debug/periphery scan --quiet --clean-build --strict
12+
periphery_scan: ./.build/debug/periphery scan --quiet --clean-build --strict --format csv
1313
cache_version: 1
1414
jobs:
1515
lint:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- Fix inconsistent unused parameter results when the function is declared in a file that is a member of multiple targets.
2626
- Fix inconsistent results caused by identical extensions declared in different modules.
2727
- Static `@_dynamicReplacement` members are now retained.
28+
- Fix possible concurrent mutation crash when accessing filename matching configuration options.
2829

2930
## 3.1.0 (2025-04-05)
3031

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ var targets: [PackageDescription.Target] = [
120120
dependencies: [
121121
.target(name: "PeripheryKit"),
122122
.target(name: "ProjectDrivers"),
123+
.target(name: "Configuration"),
123124
],
124125
path: "Tests/Shared"
125126
),

Sources/Configuration/Configuration.swift

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ public final class Configuration {
172172
}
173173
}
174174

175-
public func reset() {
176-
settings.forEach { $0.reset() }
177-
}
178-
179175
// MARK: - Helpers
180176

181177
public func apply<T: Equatable>(_ path: KeyPath<Configuration, Setting<T>>, _ value: T) {
@@ -186,35 +182,9 @@ public final class Configuration {
186182
}
187183
}
188184

189-
private var _indexExcludeMatchers: [FilenameMatcher]?
190-
public var indexExcludeMatchers: [FilenameMatcher] {
191-
if let _indexExcludeMatchers {
192-
return _indexExcludeMatchers
193-
}
194-
195-
let matchers = buildFilenameMatchers(with: indexExclude)
196-
_indexExcludeMatchers = matchers
197-
return matchers
198-
}
199-
200-
private var _retainFilesMatchers: [FilenameMatcher]?
201-
public var retainFilesMatchers: [FilenameMatcher] {
202-
if let _retainFilesMatchers {
203-
return _retainFilesMatchers
204-
}
205-
206-
let matchers = buildFilenameMatchers(with: retainFiles)
207-
_retainFilesMatchers = matchers
208-
return matchers
209-
}
210-
211-
public func resetMatchers() {
212-
_indexExcludeMatchers = nil
213-
_retainFilesMatchers = nil
214-
}
215-
185+
public lazy var indexExcludeMatchers: [FilenameMatcher] = buildFilenameMatchers(with: indexExclude)
186+
public lazy var retainFilesMatchers: [FilenameMatcher] = buildFilenameMatchers(with: retainFiles)
216187
public lazy var reportExcludeMatchers: [FilenameMatcher] = buildFilenameMatchers(with: reportExclude)
217-
218188
public lazy var reportIncludeMatchers: [FilenameMatcher] = buildFilenameMatchers(with: reportInclude)
219189

220190
// MARK: - Private
@@ -255,7 +225,6 @@ protocol AbstractSetting {
255225
var hasNonDefaultValue: Bool { get }
256226
var wrappedValue: Value { get }
257227

258-
func reset()
259228
func assign(_ value: Any)
260229
}
261230

@@ -293,10 +262,6 @@ protocol AbstractSetting {
293262
public func assign(_ newValue: Any) {
294263
value = setter(newValue) ?? defaultValue
295264
}
296-
297-
func reset() {
298-
wrappedValue = defaultValue
299-
}
300265
}
301266

302267
private let filePathSetter: (Any) -> FilePath? = { value in

0 commit comments

Comments
 (0)