Skip to content

Commit

Permalink
Merge pull request #2148 from realm/mf-attributes-rules-swift4.1
Browse files Browse the repository at this point in the history
Fix false positives in `attributes` rule with Swift 4.1
  • Loading branch information
marcelofabri authored Apr 7, 2018
2 parents c501107 + d432176 commit 94684b8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
even if only 1 file changed.
[John Szumski](https://github.com/jszumski)

* Fix false positives in `attributes` rule when using Swift 4.1.
[Marcelo Fabri](https://github.com/marcelofabri)
[#2125](https://github.com/realm/SwiftLint/issues/2125)
[#2141](https://github.com/realm/SwiftLint/issues/2141)

## 0.25.0: Cleaning the Lint Filter

#### Breaking
Expand Down
10 changes: 10 additions & 0 deletions Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,16 @@ func increase(f: @autoclosure () -> Int) -> Int
func foo(completionHandler: @escaping () -> Void)
```

```swift
private struct DefaultError: Error {}
```

```swift
@testable import foo

private let bar = 1
```

</details>
<details>
<summary>Triggering Examples</summary>
Expand Down
12 changes: 11 additions & 1 deletion Source/SwiftLintFramework/Rules/AttributesRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,17 @@ public struct AttributesRule: ASTRule, OptInRule, ConfigurationProviderRule {
"source.decl.attribute.postfix",
"source.decl.attribute.prefix",
"source.decl.attribute.required",
"source.decl.attribute.weak"
"source.decl.attribute.weak",
"source.decl.attribute.private",
"source.decl.attribute.fileprivate",
"source.decl.attribute.internal",
"source.decl.attribute.public",
"source.decl.attribute.open",
"source.decl.attribute.setter_access.private",
"source.decl.attribute.setter_access.fileprivate",
"source.decl.attribute.setter_access.internal",
"source.decl.attribute.setter_access.public",
"source.decl.attribute.setter_access.open"
]
return attributes.filter { !blacklist.contains($0) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ internal struct AttributesRuleExamples {
"@discardableResult\n func a() -> Int",
"@objc\n @discardableResult\n func a() -> Int",
"func increase(f: @autoclosure () -> Int) -> Int",
"func foo(completionHandler: @escaping () -> Void)"
"func foo(completionHandler: @escaping () -> Void)",
"private struct DefaultError: Error {}",
"@testable import foo\n\nprivate let bar = 1"
]

static let triggeringExamples = [
Expand Down

0 comments on commit 94684b8

Please sign in to comment.