Skip to content

Commit

Permalink
[UnusedDeclarationRule] Work around SR-11985 (#3363)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim authored Sep 22, 2020
1 parent a67b0f2 commit 494796b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ private extension SwiftLintFile {
return nil
}

// Work around https://bugs.swift.org/browse/SR-11985
if indexEntity.shouldSkipIndexEntityToWorkAroundSR11985() {
return nil
}

if indexEntity.enclosedSwiftAttributes.contains(where: declarationAttributesToSkip.contains) ||
indexEntity.value["key.is_implicit"] as? Bool == true ||
indexEntity.value["key.is_test_candidate"] as? Bool == true {
Expand Down Expand Up @@ -219,6 +224,30 @@ private extension SourceKittenDictionary {
}
return nil
}

func shouldSkipIndexEntityToWorkAroundSR11985() -> Bool {
guard enclosedSwiftAttributes.contains(.objcName), let name = self.name else {
return false
}

// Not a comprehensive list. Add as needed.
let functionsToSkipForSR11985 = [
"navigationBar(_:didPop:)",
"scrollViewDidEndDecelerating(_:)",
"scrollViewDidEndDragging(_:willDecelerate:)",
"scrollViewDidScroll(_:)",
"scrollViewDidScrollToTop(_:)",
"scrollViewWillBeginDragging(_:)",
"scrollViewWillEndDragging(_:withVelocity:targetContentOffset:)",
"tableView(_:canEditRowAt:)",
"tableView(_:commit:forRowAt:)",
"tableView(_:editingStyleForRowAt:)",
"tableView(_:willDisplayHeaderView:forSection:)",
"tableView(_:willSelectRowAt:)"
]

return functionsToSkipForSR11985.contains(name)
}
}

// Skip initializers, deinit, enum cases and subscripts since we can't reliably detect if they're used.
Expand Down

0 comments on commit 494796b

Please sign in to comment.