SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Add RedundantTypeAnnotationConfiguration for ignore_booleans option

Open garricn opened this issue 2 years ago • 6 comments

  • Add RedundantTypeAnnotationConfiguration for ignore_booleans option
  • Integrate with RedundantTypeAnnotationRule
  • Add RedundantTypeAnnotationConfigurationTests
  • Add RedundantTypeAnnotationRule
  • Refactor isFalsePositive logic for readability

garricn avatar Feb 08 '23 01:02 garricn

1515 Messages
:book: Linting Aerial with this PR took 0.79s vs 0.81s on main (2% faster)
:book: Linting Alamofire with this PR took 1.13s vs 1.13s on main (0% slower)
:book: Linting Brave with this PR took 6.52s vs 6.55s on main (0% faster)
:book: Linting DuckDuckGo with this PR took 3.37s vs 3.47s on main (2% faster)
:book: Linting Firefox with this PR took 9.26s vs 9.34s on main (0% faster)
:book: Linting Kickstarter with this PR took 8.33s vs 8.3s on main (0% slower)
:book: Linting Moya with this PR took 0.48s vs 0.47s on main (2% slower)
:book: Linting NetNewsWire with this PR took 2.3s vs 2.33s on main (1% faster)
:book: Linting Nimble with this PR took 0.66s vs 0.69s on main (4% faster)
:book: Linting PocketCasts with this PR took 6.95s vs 7.02s on main (0% faster)
:book: Linting Quick with this PR took 0.32s vs 0.33s on main (3% faster)
:book: Linting Realm with this PR took 4.19s vs 4.04s on main (3% slower)
:book: Linting Sourcery with this PR took 2.04s vs 2.03s on main (0% slower)
:book: Linting Swift with this PR took 3.92s vs 3.92s on main (0% slower)
:book: Linting VLC with this PR took 1.08s vs 1.09s on main (0% faster)
:book: Linting Wire with this PR took 14.34s vs 14.25s on main (0% slower)
:book: Linting WordPress with this PR took 9.83s vs 9.7s on main (1% slower)
:book: This PR fixed a violation in Aerial: /Aerial/Source/Models/Cache/VideoDownload.swift:178:20: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Aerial: /Aerial/Source/Models/Cache/VideoDownload.swift:22:34: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Aerial: /Aerial/Source/Views/AerialView.swift:97:40: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Aerial: /Aerial/Source/Views/AerialView.swift:99:27: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Brave Rewards/Panel/BraveRewardsViewController.swift:144:31: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BackForwardListAnimator.swift:9:17: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BackForwardListViewController.swift:61:22: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BackForwardTableViewCell.swift:47:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserPrompts.swift:20:18: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Menu.swift:253:41: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:136:34: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:196:39: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:804:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageFeedOverlayView.swift:110:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/New Tab Page/Sections/StatsSectionProvider.swift:176:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Browser/PlaylistChangeFoldersView.swift:31:39: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Onboarding & Toast/PlaylistToast.swift:53:21: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyReportsView.swift:22:39: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyReportsView.swift:24:41: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Search/OpenSearchEngineButton.swift:43:32: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Search/Recent Search/RecentSearchQRCodeScannerController.swift:15:22: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Search/SearchViewController.swift:67:23: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Tab.swift:134:26: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Tab.swift:176:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Tab.swift:210:25: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Tab.swift:233:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Tab.swift:86:21: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/RecentlyClosedTabs/RecentlyClosedTabsView.swift:20:41: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift:86:31: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/ToolbarVisibilityViewModel.swift:74:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift:73:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/AddEditBookmarkTableViewController.swift:64:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/PlaylistMenuButton.swift:86:23: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/VPNMenuButton.swift:34:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/HeaderContainerView.swift:20:23: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/CollapsedURLBarView.swift:107:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/CollapsedURLBarView.swift:45:23: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift:502:28: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift:58:14: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift:72:30: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Login/LoginInfoTableViewCell.swift:44:35: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Login/LoginInfoTableViewCell.swift:50:25: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Login/LoginInfoViewController.swift:56:33: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Passcode/WindowProtection.swift:115:20: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Passcode/WindowProtection.swift:94:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Rewards/BraveRewards.swift:144:38: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/Debug/BraveTalkLogsView.swift:13:31: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/Debug/BraveTalkLogsView.swift:14:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/Debug/Rewards Internals/RewardsInternalsShareController.swift:246:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/Debug/SandboxInspectorView.swift:26:31: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/ManageWebsiteDataView.swift:13:31: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/PrivacyReportSettingsView.swift:16:41: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/General/SearchEngines/SearchEnginePicker.swift:14:25: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/SettingsContentViewController.swift:23:15: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Settings/SettingsContentViewController.swift:38:26: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Shields/AdvancedControlsBarView.swift:12:32: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Shields/ShieldsSwitch.swift:23:20: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Sync/SyncSelectDeviceTypeViewController.swift:17:14: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Widgets/AutocompleteTextField.swift:33:25: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Widgets/LoadingViewController.swift:21:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/Frontend/Widgets/TwoLineCell.swift:203:20: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/Brave/WebFilters/FilterList.swift:47:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveNews/Composer/FeedCardGenerator.swift:94:38: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveNews/Composer/FeedCardGenerator.swift:95:39: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveNews/Customize/FollowToggle.swift:65:28: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveNews/Customize/NewsSettingsView.swift:135:41: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveNews/Customize/NewsSettingsView.swift:32:32: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveNews/Customize/NewsSettingsView.swift:346:27: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveNews/Customize/OptInView.swift:17:31: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveTalk/BraveTalkJitsiCoordinator.swift:53:22: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveTalk/BraveTalkJitsiCoordinator.swift:54:47: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveTalk/BraveTalkJitsiCoordinator.swift:55:39: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/Buttons/BraveButton.swift:115:27: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/Buttons/BraveButton.swift:30:21: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/Buttons/LoaderView.swift:135:30: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/Buttons/LoaderView.swift:63:38: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/SwiftUI/AlertOnScreenshotViewModifier.swift:11:39: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/SwiftUI/CustomPrivacySensitiveModifier.swift:14:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/SwiftUI/CustomPrivacySensitiveModifier.swift:15:32: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/SwiftUI/ListInitialOffsetWorkaround.swift:11:34: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/SwiftUI/LottieAnimationView.swift:37:18: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/SwiftUI/NoCaptureViewModifier.swift:10:32: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/SwiftUI/Shimmer.swift:68:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/UIKit/UIKitPopupView.swift:115:23: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/UIKit/UIKitPopupView.swift:117:25: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveUI/UIKit/UIKitPopupView.swift:118:37: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveVPN/BraveVPN.swift:358:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveVPN/BraveVPN.swift:359:25: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveVPN/BraveVPNPickerViewController.swift:30:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveVPN/BraveVPNSettingsViewController.swift:50:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveVPN/BuyVPNViewController.swift:269:16: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/AccountSelectionView.swift:17:44: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Activity/AccountActivityView.swift:20:29: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Activity/AccountActivityView.swift:21:45: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Activity/AccountActivityView.swift:22:47: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Add/AddAccountView.swift:17:40: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Add/AddAccountView.swift:18:35: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Add/AddAccountView.swift:20:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Details/AccountDetailsView.swift:23:36: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Accounts/Details/AccountDetailsView.swift:24:52: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift:24:48: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift:25:44: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift:26:56: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift:28:46: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift:43:48: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/AssetIconView.swift:136:28: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/AssetIconView.swift:138:24: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/AssetIconView.swift:63:28: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/BuySendSwap/AccountPicker.swift:14:40: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/BuySendSwap/SendTokenView.swift:21:53: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/BuySendSwap/SwapCryptoView.swift:171:45: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/CryptoTabsView.swift:37:39: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/CryptoTabsView.swift:39:37: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/CryptoTabsView.swift:40:37: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/CryptoTabsView.swift:41:41: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/CryptoTabsView.swift:42:55: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift:139:45: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/NFT/NFTDetailView.swift:23:45: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/NFT/NFTView.swift:20:48: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/NFT/NFTView.swift:21:43: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/NFTImageView.swift:68:14: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:book: This PR fixed a violation in Brave: /Sources/BraveWallet/Crypto/NetworkPicker.swift:27:44: warning: Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)
:warning: Danger found 1515 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 139.

Generated by :no_entry_sign: Danger

SwiftLintBot avatar Feb 08 '23 01:02 SwiftLintBot

An observation for this rule in general: The exception for Bool seems to be quite arbitrary. What about var j: Int = 7 or var d: Double = 1.3 or let s: String = "my string"?

I wonder if we should rather extend the rule for these cases and rename the new option ignore_booleans to ignore_literals.

@revolter: You added the exception for Bool back then. Anything that speaks against my suggestions?

SimplyDanny avatar Feb 18 '23 13:02 SimplyDanny

An observation for this rule in general: The exception for Bool seems to be quite arbitrary. What about var j: Int = 7 or var d: Double = 1.3 or let s: String = "my string"?

I wonder if we should rather extend the rule for these cases and rename the new option ignore_booleans to ignore_literals.

@revolter: You added the exception for Bool back then. Anything that speaks against my suggestions?

Hi @SimplyDanny, thank you for your observation. The examples you gave are not currently triggering examples and booleans are the only literals that currently violate this rule. It makes sense that numeric and string literals are not violations since you may need to be explicit that the type in let foo = 0 is actually an Int, Double, or Float. Or, in let foo = "someString", you may need to be explicit that foo is a String or StaticString. This is why we made the determination to implement this as ignore_booleans instead of something like ignore_literals.

garricn avatar Feb 21 '23 20:02 garricn

Well, without the explizit types, the variables j, d and s would have the same type as specified. They are the defaults.

The current implementation checks exactly for the combinations Bool = true and Bool = false. The same could be done for Int = <any integer>, Double = <any float>, ...

Moreover, a variable being assigned a Boolean literal is not necessarily a Bool. That also works for types conforming to ExpressibleByBooleanLiteral.

The exception for Bool is still not clear to me yet.

SimplyDanny avatar Feb 21 '23 21:02 SimplyDanny

Well, without the explizit types, the variables j, d and s would have the same type as specified. They are the defaults.

The current implementation checks exactly for the combinations Bool = true and Bool = false. The same could be done for Int = <any integer>, Double = <any float>, ...

Moreover, a variable being assigned a Boolean literal is not necessarily a Bool. That also works for types conforming to ExpressibleByBooleanLiteral.

The exception for Bool is still not clear to me yet.

Thank you for your reply @SimplyDanny. The original intent for the special handling of Bool is not discernible from the PR or the issue.

My guess is that we would not want any of the following to be violations because, in certain cases, we might need to be explicit about the type:

let someInt: Int = 0
let someDouble: Double = 0
let someFloat: Float = 0
let someString: String = "foo"
let someStaticString: StaticString =  "bar"
let someCustomBool: CustomBool = false

However, in the case of Bool, we do not need to be explicit when defining one because Bool is the only conforming type to ExpressibleByBooleanLiteral in the Swift Standard Library.

https://developer.apple.com/documentation/swift/expressiblebystringliteral#conforming-types https://developer.apple.com/documentation/swift/expressiblebyintegerliteral#conforming-types https://developer.apple.com/documentation/swift/expressiblebyfloatliteral#conforming-types

Granted, you can create your own type that is ExpressibleByBooleanLiteral (like CustomBool above), but in that case you would want to be explicit about the type and you would not want the rule to trigger a violation.

Although I think your point is a valuable one, I believe it is outside the scope of this PR and so I'd like to suggest the following way forward:

  1. Move ahead with this PR as is
  2. Separately from this PR, other PRs in the future could consider removing custom handling of booleans or alternatively adding custom handling for all literal types

garricn avatar Feb 28 '23 02:02 garricn

Although I think your point is a valuable one, I believe it is outside the scope of this PR and so I'd like to suggest the following way forward:

  1. Move ahead with this PR as is
  2. Separately from this PR, other PRs in the future could consider removing custom handling of booleans or alternatively adding custom handling for all literal types

That might be an acceptable way to go. However, I still take exception to the option's name ignore_booleans which is obviously very specific for Booleans. Changing an options name later on might cause trouble for users, unfortunately. That's why I'm still opposed to just adding it immediately.

SimplyDanny avatar Mar 02 '23 21:03 SimplyDanny

Reading through the comments, it really feels like the decision to have let someBool: Bool = true violate a rule named RedundantTypeAnnotation was possibly not the best decision in the first place, and is likely the cause for some confusion I am seeing in the comments.

I would like to reiterate that var j: Int = 7, var d: Double = 1.3 and let s: String = "my string" do NOT violate RedundantTypeAnnotation. For some reason only the boolean check was added to RedundantTypeAnnotation (and hence why this PR is proposing only adding the exception for booleans – there would be no reason for the option to be ignore_literals since the other literals are not violations).

I would like to kindly suggest an alternative way forward:

  • Revise this pull request to instead completely remove the boolean check from RedundantTypeAnnotation.
  • Submit another pull request to add a new opt-in rule to treat boolean literals with explicit type annotations as violations named BooleanLiteralTypeAnnotation – or LiteralTypeAnnotation if it is preferred that all literals with explicit types are violations.

With this approach, there is no need for a configuration option at all.

@SimplyDanny Would this alternative approach be accepted? And do you prefer BooleanLiteralTypeAnnotation or LiteralTypeAnnotation for the new rule?

Thank you 🙏

tinder-cfuller avatar Mar 23 '24 14:03 tinder-cfuller

For clarity: I was the one that requested this (in #3423), but I didn't make any code change for it.


As far as the current situation goes, I would be fine with reverting that change completely.

Bool is the only conforming type to ExpressibleByBooleanLiteral in the Swift Standard Library

but this can change in the future, so I would say that considering

let test: Bool = true

to be redundant is a guess, while considering

let test: URL = URL()

to be redundant is a certainty.

revolter avatar Mar 26 '24 15:03 revolter

I'd like to avoid exceptions for certain cases that actually should follow the same rules as others. Breaking changes are acceptable if they really fix an inconstancy or harmonize implementations.

The exception for booleans bugs me, with or without the ignore_booleans option.

Types can conform to any ExpressibleBy...Literal to make them be initializable with the corresponding literal. But all literals are as well associated with a default type. So if the rule talks about "redundant types" I'd consider explicit default types for literals redundant. Booleans follow the same logic; I don't see why there ought to be any special handling for them (as of now or with an option).

Since there might be people not agreeing on the statement that default types can be considered redundant, my favorite is still this ignore_literals or perhaps the better consider_default_literal_types_redundant to be more specific. With that set to true,

let k: Int = 0
let d: Double = 0.0
let s: String = ""
let b: Bool = false

would all trigger while

let k: Int8 = 0
let d: Double = 0
let s: Name = ""
let b: OnOff = true

would not.

SimplyDanny avatar Mar 29 '24 12:03 SimplyDanny

@SimplyDanny Thank you for weighing in. Very much appreciated 👍

So, to confirm, you are suggesting that on this PR, the ignore_booleans option be renamed to consider_default_literal_types_redundant, defaulted to true, is that correct?

As far as treating Int, Double and String literals as redundant, are you suggesting that this capability is also added on this PR as well? Asking since those are not treated as redundant currently and we are seeking to have this PR merged in sooner than later, so would like to optimize the changes for your approval. Please confirm. Thank you!

tinder-cfuller avatar Mar 29 '24 14:03 tinder-cfuller

So, to confirm, you are suggesting that on this PR, the ignore_booleans option be renamed to consider_default_literal_types_redundant, defaulted to true, is that correct?

Yes, that's what feels most reasonable to me. However, the default should be false so that for most types/literals this doesn't change the rule's behavior - only for Bool in that the rule with default settings wouldn't trigger on let b: Bool = true while it currently does. For people already having the rule active, no surprising behavioral changes would come with an update to a new SwiftLint version in that way.

Any noticeable flaw in my reasoning?

SimplyDanny avatar Mar 29 '24 14:03 SimplyDanny

@SimplyDanny Sounds good 👍 … consider_default_literal_types_redundant will default to false. Thank you for confirming that.

And may treating Int, Double and String literals as redundant be added on a separate PR (potentially by someone else), to limit the scope of the change on this PR?

tinder-cfuller avatar Mar 29 '24 14:03 tinder-cfuller

And may treating Int, Double and String literals as redundant be added on a separate PR (potentially by someone else), to limit the scope of the change on this PR?

Well, ideally we would have all types properly supported right from the new option's introduction on. 😉

SimplyDanny avatar Mar 29 '24 15:03 SimplyDanny

@SimplyDanny Thanks again for all the feedback. I investigated adding validations for Int, Double and String literals and determined that an overhaul of the rule, potentially adopting SwiftSyntax, would likely be required. Since that would significantly increase the scope and complexity of the PR, I propose that the PR is limited to adding the new config option only. I've updated to use the option renamed as you requested, and it's working really well! My hope is that you will consider merging this as is and allow the additional type support to be added later. I look forward to hearing back from you. Thank you 😄

garricn avatar Apr 17 '24 01:04 garricn

@SimplyDanny Thanks again for all the feedback. I investigated adding validations for Int, Double and String literals and determined that an overhaul of the rule, potentially adopting SwiftSyntax, would likely be required. Since that would significantly increase the scope and complexity of the PR, I propose that the PR is limited to adding the new config option only. I've updated to use the option renamed as you requested, and it's working really well! My hope is that you will consider merging this as is and allow the additional type support to be added later. I look forward to hearing back from you. Thank you 😄

The rewrite with SwiftSyntax is now done with #5389 just being merged. I would still appreciate you implementing all cases to have this in a complete and reasonable shape. With the rewrite, this ought not to be that complex. Otherwise, we need to wait for me or another contributor to find the time to address this.

SimplyDanny avatar Apr 21 '24 15:04 SimplyDanny

@SimplyDanny The rewrite of the rule with SwiftSyntax makes this much more straightforward! Very cool! 👍

@garricn Thank you for implementing this! ❤️

tinder-cfuller avatar Apr 24 '24 02:04 tinder-cfuller

I do have one question though, which is whether we need to indicate somewhere that Bool literals will no longer be considered redundant by default. Since this is a change in behavior, does it need to be listed as a "breaking" change?

Yes, I'd like that.

SimplyDanny avatar Apr 26 '24 05:04 SimplyDanny

@SimplyDanny Thanks for all your guidance and attention on this! Very much appreciated ⭐

@garricn Great work! Thank you again for making this improvement.

tinder-cfuller avatar May 01 '24 19:05 tinder-cfuller

Just to let you guys know: I made a few cleanups to reduce some duplications in #5554. Didn't want to prolong the review here while being pedantic. 😅

I also enabled the option directly in SwiftLint itself (#5555).

SimplyDanny avatar May 01 '24 19:05 SimplyDanny

@SimplyDanny That's great! 👏

tinder-cfuller avatar May 01 '24 20:05 tinder-cfuller