From 03f13e5bb7b71a71c2382661a5f4071c6571cf58 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 3 Dec 2020 11:00:53 -0800 Subject: [PATCH] Remove @IBOutlet and @IBInspectable from UnusedDeclarationRule (#3432) The original implementation wasn't tested so it regressed. https://github.com/realm/SwiftLint/pull/3184 --- CHANGELOG.md | 4 ++- .../Rules/Lint/UnusedDeclarationRule.swift | 2 -- .../Lint/UnusedDeclarationRuleExamples.swift | 28 +++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index feccc682a6..81368168eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,7 +86,9 @@ #### Bug Fixes -* None. +* Remove `@IBOutlet` and `@IBInspectable` from UnusedDeclarationRule. + [Keith Smiley](https://github.com/keith) + [#3184](https://github.com/realm/SwiftLint/issues/3184) ## 0.41.0: World’s Cleanest Voting Booth diff --git a/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRule.swift b/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRule.swift index ad56ec0d6c..aea5d93efe 100644 --- a/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRule.swift +++ b/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRule.swift @@ -268,8 +268,6 @@ private let declarationKindsToSkip: Set = [ private let declarationAttributesToSkip: Set = [ .ibaction, - .ibinspectable, - .iboutlet, .main, .nsApplicationMain, .override, diff --git a/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRuleExamples.swift b/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRuleExamples.swift index ac3043da07..224036b950 100644 --- a/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRuleExamples.swift +++ b/Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRuleExamples.swift @@ -126,6 +126,20 @@ struct UnusedDeclarationRuleExamples { func applicationWillFinishLaunching(_ notification: Notification) {} func applicationWillBecomeActive(_ notification: Notification) {} } + """), + Example(""" + import Foundation + + public final class Foo: NSObject { + @IBAction private func foo() {} + } + """), + Example(""" + import Foundation + + public final class Foo: NSObject { + @objc func foo() {} + } """) ] @@ -146,6 +160,20 @@ struct UnusedDeclarationRuleExamples { func applicationWillFinishLaunching(_ notification: Notification) {} func applicationWillBecomeActive(_ notification: Notification) {} } + """), + Example(""" + import Foundation + + public final class Foo: NSObject { + @IBOutlet var ↓bar: NSObject! + } + """), + Example(""" + import Foundation + + public final class Foo: NSObject { + @IBInspectable var ↓bar: String! + } """) ] #else