Given
#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
import LibC
#elseif canImport(FoundationEssentials)
// Platforms that don't have clock_gettime.
import FoundationEssentials
#endif
struct Instant {
let value: Double
#if canImport(Darwin) || canImport(Glibc)
init() {
var time = timespec()
clock_gettime(CLOCK_MONOTONIC_RAW, &time)
value = Double(time.tv_sec) + (Double(time.tv_nsec) / 1_000_000_000)
}
#elseif canImport(FoundationEssentials)
init() {
value = Date.now.timeIntervalSinceReferenceDate
}
#endif
}
When running with blankLinesBetweenScopes enabled, this is the output:
```swift
#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
import LibC
#elseif canImport(FoundationEssentials)
// Platforms that don't have clock_gettime.
import FoundationEssentials
#endif
struct Instant {
let value: Double
#if canImport(Darwin) || canImport(Glibc)
init() {
var time = timespec()
clock_gettime(CLOCK_MONOTONIC_RAW, &time)
value = Double(time.tv_sec) + (Double(time.tv_nsec) / 1_000_000_000)
}
#elseif canImport(FoundationEssentials)
init() {
value = Date.now.timeIntervalSinceReferenceDate
}
#endif
}
This is unexpected (to me) for two reasons:
- I wouldn't consider
#if directives scopes for the purpose of the rule.
- If it is a scope for the rules, I would expect a similar newline added at the end of the other
init, but it's not.
I'm not sure what the intention is here. If 1, then the rule should be fixed. If 2, then I'd appreciate a an option added to not add a newline when in #if directives and it should be fixed to add the newline for the second init.
Given
When running with
blankLinesBetweenScopesenabled, this is the output:This is unexpected (to me) for two reasons:
#ifdirectives scopes for the purpose of the rule.init, but it's not.I'm not sure what the intention is here. If 1, then the rule should be fixed. If 2, then I'd appreciate a an option added to not add a newline when in
#ifdirectives and it should be fixed to add the newline for the secondinit.