Ignores computed variables

This commit is contained in:
Ornithologist Coder
2018-01-05 10:41:05 +01:00
parent 561e10a71f
commit a2c8233d95
2 changed files with 31 additions and 3 deletions
+19 -1
View File
@@ -9022,7 +9022,19 @@ var foo = true, let kFoo = true
```swift
let
kFoo = true
kFoo = true
```
```swift
var foo: Int {
return a + b
}
```
```swift
let kFoo = {
return a + b
}()
```
</details>
@@ -9058,6 +9070,12 @@ let
foo = true
```
```swift
let foo = {
return a + b
}()
```
</details>
@@ -36,7 +36,13 @@ public struct PrefixedTopLevelConstantRule: ASTRule, OptInRule, ConfigurationPro
"var foo = true, bar = true",
"var foo = true, let kFoo = true",
"let\n" +
" kFoo = true"
" kFoo = true",
"var foo: Int {\n" +
" return a + b\n" +
"}",
"let kFoo = {\n" +
" return a + b\n" +
"}()"
],
triggeringExamples: [
"private let ↓Foo = 20.0",
@@ -46,7 +52,10 @@ public struct PrefixedTopLevelConstantRule: ASTRule, OptInRule, ConfigurationPro
"let ↓foo = 2, ↓bar = true",
"var foo = true, let ↓Foo = true",
"let\n" +
" ↓foo = true"
" ↓foo = true",
"let ↓foo = {\n" +
" return a + b\n" +
"}()"
]
)
@@ -56,6 +65,7 @@ public struct PrefixedTopLevelConstantRule: ASTRule, OptInRule, ConfigurationPro
guard
kind == .varGlobal,
dictionary.setterAccessibility == nil,
dictionary.bodyLength == nil,
dictionary.name?.hasPrefix(topLevelPrefix) == false,
let nameOffset = dictionary.nameOffset
else {