mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Ignores computed variables
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user