Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TestCaseAccessibilityRule #3376

Merged
merged 7 commits into from
Oct 12, 2020
Merged

Conversation

keith
Copy link
Collaborator

@keith keith commented Oct 7, 2020

This rule verifies that all members of XCTestCase subclasses are private
(or fileprivate) except for those defined by XCTestCase. This is useful
for a few things:

  1. You can make sure code that isn't needed outside the test case isn't
    overly accessible
  2. You can catch typos like func tsetSomething that won't actually be
    run

This rule has configuration for method_prefixes so that custom methods
can still be allowed. This is useful if you disable tests by renaming
them (so they continue to be compiled) like func disabled_testFoo

This change also extracts some useful shared logic around identifying
what members are provided by XCTest since they are now used in multiple
places.

This rule verifies that all members of XCTestCase subclasses are private
(or fileprivate) except for those defined by XCTestCase. This is useful
for a few things:

1. You can make sure code that isn't needed outside the test case isn't
   overly accessible
2. You can catch typos like `func tsetSomething` that won't actually be
   run

This rule has configuration for `method_prefixes` so that custom methods
can still be allowed. This is useful if you disable tests by renaming
them (so they continue to be compiled) like `func disabled_testFoo`

This change also extracts some useful shared logic around identifying
what members are provided by XCTest since they are now used in multiple
places.
@SwiftLintBot
Copy link

SwiftLintBot commented Oct 7, 2020

430 Warnings
⚠️ This PR introduced a violation in Alamofire: /Tests/BaseTestCase.swift:30:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Alamofire: /Tests/BaseTestCase.swift:32:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Alamofire: /Tests/BaseTestCase.swift:33:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Alamofire: /Tests/BaseTestCase.swift:42:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Alamofire: /Tests/BaseTestCase.swift:52:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Alamofire: /Tests/ProtectedTests.swift:63:16: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /MarketingUITests/MarketingUITests.swift:9:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /MarketingUITests/MarketingUITests.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /MarketingUITests/MarketingUITests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /MarketingUITests/MarketingUITests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /MarketingUITests/MarketingUITests.swift:33:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/ProfileTest.swift:20:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/ProfileTest.swift:30:4: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/FxAPushMessageTest.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/BreachAlertsTests.swift:49:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/BreachAlertsTests.swift:50:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/BreachAlertsTests.swift:51:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/LoginsListSelectionHelperTests.swift:9:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/LoginsListDataSourceHelperTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/LoginsListViewModelTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/LoginsListViewModelTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/NavigationRouterTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/DownloadQueueTests.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/DownloadQueueTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/DownloadQueueTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/DownloadQueueTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/DownloadQueueTests.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/DownloadQueueTests.swift:16:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/UpdateCoverSheet/UpdateCoverSheetViewModelTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/WebServerTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/WebServerTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/FirefoxHomeTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/FirefoxHomeTests.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:16:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:17:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:18:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:19:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabToolbarHelperTests.swift:20:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerStoreTests.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerStoreTests.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerStoreTests.swift:16:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerStoreTests.swift:40:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/HomePageTests.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/PrefsTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/ETPCoverSheet/ETPCoverSheetTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TPStatsBlocklistsTests.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/PocketFeedTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/PocketFeedTests.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/RustLoginsTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/RustLoginsTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/RustLoginsTests.swift:26:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteMetadata.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteMetadata.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteMetadata.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSwiftData.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSwiftData.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSwiftData.swift:16:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestBrowserDB.swift:16:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestBrowserDB.swift:35:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerTests.swift:91:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerTests.swift:92:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerTests.swift:94:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerTests.swift:95:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /ClientTests/TabManagerTests.swift:96:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/SyncCommandsTests.swift:23:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/SyncCommandsTests.swift:24:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/SyncCommandsTests.swift:26:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/SyncCommandsTests.swift:28:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/SyncCommandsTests.swift:29:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/SyncCommandsTests.swift:30:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteRemoteClientsAndTabs.swift:137:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteRemoteClientsAndTabs.swift:139:10: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/DiskImageStoreTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/DiskImageStoreTests.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteReadingList.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteReadingList.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteReadingList.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteReadingList.swift:153:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteReadingList.swift:159:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteReadingList.swift:165:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteReadingList.swift:171:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /StorageTests/TestSQLiteHistory.swift:918:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:39:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:45:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:59:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:66:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /L10nSnapshotTests/L10nBaseSnapshotTests.swift:71:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/ScreenGraphTest.swift:9:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/ScreenGraphTest.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:16:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:17:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:20:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:24:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:26:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:31:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:48:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:53:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:64:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:73:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:77:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:81:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:95:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:112:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:119:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /XCUITests/BaseTestCase.swift:126:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /PushTests/LivePushClientTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /PushTests/LivePushClientTests.swift:16:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /PushTests/PushCryptoTests.swift:10:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /PushTests/PushCryptoTests.swift:37:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /PushTests/PushCryptoTests.swift:125:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SharedTests/RollingFileLoggerTests.swift:11:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SharedTests/RollingFileLoggerTests.swift:12:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SharedTests/RollingFileLoggerTests.swift:13:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SharedTests/FeatureSwitchTests.swift:9:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/StateTests.swift:61:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/StateTests.swift:66:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/StateTests.swift:70:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:14:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:15:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:17:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:18:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:20:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:22:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:24:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/CryptoTests.swift:44:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ This PR introduced a violation in Firefox: /SyncTests/DownloadTests.swift:17:5: warning: Test case accessibility Violation: Test cases should only contain private non-test members. (test_case_accessibility)
⚠️ Danger found 430 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 136.
12 Messages
📖 Linting Aerial with this PR took 1.95s vs 1.95s on master (0% slower)
📖 Linting Alamofire with this PR took 2.73s vs 2.72s on master (0% slower)
📖 Linting Firefox with this PR took 9.2s vs 9.29s on master (0% faster)
📖 Linting Kickstarter with this PR took 15.45s vs 15.37s on master (0% slower)
📖 Linting Moya with this PR took 1.36s vs 1.31s on master (3% slower)
📖 Linting Nimble with this PR took 1.4s vs 1.38s on master (1% slower)
📖 Linting Quick with this PR took 0.63s vs 0.65s on master (3% faster)
📖 Linting Realm with this PR took 2.71s vs 2.74s on master (1% faster)
📖 Linting SourceKitten with this PR took 1.04s vs 1.04s on master (0% slower)
📖 Linting Sourcery with this PR took 7.15s vs 7.1s on master (0% slower)
📖 Linting Swift with this PR took 10.91s vs 10.96s on master (0% faster)
📖 Linting WordPress with this PR took 17.26s vs 17.23s on master (0% slower)

Generated by 🚫 Danger

@codecov-io
Copy link

codecov-io commented Oct 8, 2020

Codecov Report

Merging #3376 into master will increase coverage by 0.02%.
The diff coverage is 79.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3376      +/-   ##
==========================================
+ Coverage   90.48%   90.51%   +0.02%     
==========================================
  Files         417      420       +3     
  Lines       20508    20552      +44     
==========================================
+ Hits        18557    18602      +45     
+ Misses       1951     1950       -1     
Impacted Files Coverage Δ
...gurations/TestCaseAccessibilityConfiguration.swift 28.57% <28.57%> (ø)
...rce/SwiftLintFramework/Helpers/XCTestHelpers.swift 100.00% <100.00%> (ø)
...ntFramework/Rules/Lint/EmptyXCTestMethodRule.swift 100.00% <100.00%> (ø)
...amework/Rules/Lint/TestCaseAccessibilityRule.swift 100.00% <100.00%> (ø)
...nfigurations/OverridenSuperCallConfiguration.swift 91.93% <100.00%> (+0.26%) ⬆️
...tFrameworkTests/AutomaticRuleTests.generated.swift 100.00% <100.00%> (ø)
...tyle/MultipleClosuresWithTrailingClosureRule.swift 85.52% <0.00%> (+1.31%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da408b5...33e8b93. Read the comment docs.

Copy link
Collaborator

@jpsim jpsim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and useful! I just have a few questions/suggestions.

@keith
Copy link
Collaborator Author

keith commented Oct 9, 2020

Updated to more accurately identify XCTestCase members


public var consoleDescription: String {
return severityConfiguration.consoleDescription +
", method_prefixes: [\(methodPrefixes)]"
", allowed_prefixes: [\(allowedPrefixes)]"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examples can now specify configurations, so it'd be nice to test something like disabled_test as an allowed prefix.

/// The untyped configuration to apply to the rule, if deviating from the default configuration.
/// The structure should match what is expected as a configuration value for the rule being tested.
///
/// For example, if the following YAML would be used to configure the rule:
///
/// ```
/// severity: warning
/// ```
///
/// Then the equivalent configuration value would be `["severity": "warning"]`.
public private(set) var configuration: Any?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an example of that working? I tried that and I don't believe it's passed all the way through the tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT it only is for analyze tests

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I think you're right. Let's hold off for now, but it should be easy to make normal lint tests apply this configuration value.

return false
static func isXCTestMember(kind: SwiftDeclarationKind, name: String,
attributes: [SwiftDeclarationAttributeKind]) -> Bool {
return attributes.contains(.override)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Copy link
Collaborator

@jpsim jpsim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really useful rule, thanks!

@keith keith merged commit 5d6e25a into master Oct 12, 2020
@keith keith deleted the ks/add-testcaseaccessibilityrule branch October 12, 2020 15:59
@davidelorenzitw
Copy link

Nice rule!
There are cases where the test class is also implementing protocols (ie. for testing some delegate callback, rather than having to create a new mocked type that the test instantiates and checks), and these functions/properties can't be declared as private, meaning this new rule can't be used in those cases. (note: function prefix configuration can't be applied here)

So maybe a possible improvement to consider: would it be possible to ie. only execute this rule's check within the main class declaration, and skip any extension declared on the test class instead? This would give some room in how to organise the class definition while still having this rule enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants