to avoid having to lock calls to mutating functions that don't
actually perform mutating operations.
This fixes races seen "in the wild" causing crashes.
This has never worked for two reasons:
1. We've used dictionaries to represent cache descriptions, which
don't guarantee stable ordering of keys across invocations.
This is true both on Darwin and Linux, but in practice ordering
varies significantly more on Linux.
2. Storing a `TimeInterval` value in a `[String: Any]` dictionary
and retrieving it again will not be dynamically castable to
`Double` or `TimeInterval` but will be castable to `Int`.
* Fix superfluous disable command producing false positives
* Fix import formatting assumptions:
* Exactly once space after `import`
* No support for `@testable import`
* Reduce indentation
* Omit types when they can be inferred
* Omit explicit references to `self.`
* Fix typos in comments
* Make constrained extensions more generic
* Use explicit ACLs for all declarations
For a function that takes a closure as default value, the array of
parameter reported by sourcekit also includes the parameters of that
closure.
In other words, a function like
func foo(param1: Int,
param2: Bool,
param3: (Int) -> Void = { (x: Int) in }) { }
reports 4 parameters (param 1, param2, param3, and x).
This commit uses the bounds of the method/function parameters to filter
out parameters within parameters. Below, a 1, a 2, and a 3 would be
filtered out since they're inside parameter 3.
----------------------------------------------------------------|
| |---------| |---------| |----------------------------| |
| | param 1 | | param 2 | | param 3: |a 1| |a 2| |a 3| | |
| |---------| |---------| |----------------------------| |
----------------------------------------------------------------|
also slightly speed up writing to the cache.
For example, on the Lyft codebase with 1,500 Swift files:
```bash
$ time swiftlint lint --quiet
swiftlint --quiet 3.53s user 0.27s system 388% cpu 0.979 total
$ rm -rf ~/Library/Caches/SwiftLint && time swiftlint lint --quiet
swiftlint --quiet 35.20s user 1.22s system 371% cpu 9.806 total
$ time swiftlint lint --quiet
swiftlint lint --quiet 0.90s user 0.13s system 218% cpu 0.472 total
$ rm -rf ~/Library/Caches/SwiftLint && time swiftlint lint --quiet
swiftlint lint --quiet 31.78s user 1.18s system 360% cpu 9.146 total
```