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 Cognitive Complexity Rule #5838

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

lorwe
Copy link

@lorwe lorwe commented Oct 28, 2024

@SwiftLintBot
Copy link

659 Warnings
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/API/Forecast.swift:161:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Aerial.swift:374:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Cache/Cache.swift:378:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Cache/Cache.swift:609:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Cache/Cache.swift:704:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 30 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Cache/PoiStringProvider.swift:165:13: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Cache/VideoLoader.swift:94:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Extensions/NSImage+trim.swift:28:13: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 28 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Hardware/NightShift.swift:41:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 22 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/ManifestLoader.swift:929:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Music/Music.swift:78:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 29 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Sources/Sidebar.swift:58:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 31 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Sources/Source.swift:182:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 26 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Sources/Source.swift:365:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Sources/Source.swift:437:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 26 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Sources/SourceList.swift:166:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Sources/VideoList.swift:425:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Time/TimeManagement.swift:45:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 32 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/AerialView.swift:237:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 34 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/AerialView.swift:774:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 24 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/AerialView.swift:900:14: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/Layers/Weather/ForecastLayer.swift:17:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 36 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/PrefPanel/DisplayView.swift:58:14: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 38 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/PrefPanel/InfoWeatherView.swift:126:15: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 23 (cognitive_complexity)
⚠️ This PR introduced a violation in Aerial: /Resources/MainUI/VideosViewController.swift:401:5: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/Request.swift:1002:12: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 29 (cognitive_complexity)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/URLEncodedFormEncoder.swift:585:13: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Alamofire: /Tests/ProtectedTests.swift:168:13: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 19 (cognitive_complexity)
⚠️ This PR introduced a violation in Alamofire: /Tests/ProtectedTests.swift:224:13: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 19 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /App/iOS/Delegates/SceneDelegate.swift:287:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 24 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /App/iOS/Delegates/SceneDelegate.swift:40:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 24 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Plugins/LeoAssetsPlugin/LeoAssetsPlugin.swift:104:15: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/DeviceCheck/DeviceCheck.swift:318:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 25 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Brave Notifications/BraveNotificationsPresenter.swift:54:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 19 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Callout.swift:237:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 19 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Menu.swift:124:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 22 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Menu.swift:49:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Onboarding.swift:185:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Playlist.swift:101:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 25 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ProductNotification.swift:32:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ProductNotification.swift:83:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 22 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ReaderMode.swift:159:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ShareActivity.swift:16:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 74 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabManagerDelegate.swift:19:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 30 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabManagerDelegate.swift:226:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 52 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift:231:22: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift:354:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 23 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift:64:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift:652:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 50 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift:823:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift:1225:10: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 40 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift:1403:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift:153:10: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 91 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift:497:10: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 23 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift:611:22: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift:755:10: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift:918:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 26 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:192:10: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:600:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Widgets.swift:17:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:1264:19: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 49 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:1716:19: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 92 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:2293:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:276:10: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:3075:10: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:3343:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:449:15: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 29 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift:860:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Favorites/FavoritesViewController.swift:601:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 23 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Favorites/PreloadedFavorites.swift:12:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/FrequencyQuery.swift:78:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Handlers/ReaderModeHandler.swift:20:10: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 41 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift:106:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageFlowLayout.swift:61:12: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift:559:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift:943:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 23 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/New Tab Page/Sections/BraveNewsSectionProvider.swift:155:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/New Tab Page/Sections/BraveNewsSectionProvider.swift:240:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistCarplayController.swift:106:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 34 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistCarplayController.swift:364:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 30 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistCarplayController.swift:71:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistCarplayController.swift:953:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 17 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistListViewController+TableViewDataSource.swift:156:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 53 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistListViewController+TableViewDataSource.swift:76:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistListViewController.swift:238:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 19 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistListViewController.swift:670:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistListViewController.swift:846:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistViewController.swift:324:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 37 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Controllers/PlaylistViewController.swift:693:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Managers & Cache/PlaylistCacheLoader.swift:141:5: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 24 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Managers & Cache/PlaylistCacheLoader.swift:281:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Managers & Cache/PlaylistCacheLoader.swift:407:15: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/VideoPlayer/UI/VideoPlayer.swift:283:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 44 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Search/OpenSearch.swift:249:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 47 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Search/SearchSuggestClient.swift:34:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Search/SearchViewController.swift:377:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Search/SearchViewController.swift:517:19: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 27 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:303:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 20 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:508:14: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 23 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:625:14: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 36 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabBar/TabsBarViewController.swift:468:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/AddEditBookmarkTableViewController.swift:254:9: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/BookmarksViewController.swift:354:15: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 26 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/BookmarksViewController.swift:467:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/BookmarksViewController.swift:539:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/UserScriptManager.swift:273:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 27 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Login/LoginListDataSource.swift:103:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/Debug/Rewards Internals/RewardsInternalsShareController.swift:132:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 19 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/Debug/SandboxInspectorView.swift:34:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 16 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/AdvancedShieldSettings.swift:114:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 19 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/SettingsViewController.swift:236:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 21 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Sync/SyncWelcomeViewController.swift:346:11: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 26 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/ContentBlockerScriptHandler.swift:50:3: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 35 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/CosmeticFiltersScriptHandler.swift:39:3: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/EthereumProviderScriptHandler.swift:63:14: error: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 28 (cognitive_complexity)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/PlaylistScriptHandler.swift:115:11: warning: Cognitive Complexity Violation: Function should have cognitive complexity 15 or less; currently complexity is 18 (cognitive_complexity)
⚠️ Danger found 659 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 116.
17 Messages
📖 Linting Aerial with this PR took 0.93s vs 0.93s on main (0% slower)
📖 Linting Alamofire with this PR took 1.27s vs 1.27s on main (0% slower)
📖 Linting Brave with this PR took 7.22s vs 7.22s on main (0% slower)
📖 Linting DuckDuckGo with this PR took 5.09s vs 5.09s on main (0% slower)
📖 Linting Firefox with this PR took 10.65s vs 10.63s on main (0% slower)
📖 Linting Kickstarter with this PR took 9.86s vs 9.88s on main (0% faster)
📖 Linting Moya with this PR took 0.53s vs 0.53s on main (0% slower)
📖 Linting NetNewsWire with this PR took 2.63s vs 2.63s on main (0% slower)
📖 Linting Nimble with this PR took 0.78s vs 0.77s on main (1% slower)
📖 Linting PocketCasts with this PR took 8.57s vs 8.56s on main (0% slower)
📖 Linting Quick with this PR took 0.44s vs 0.45s on main (2% faster)
📖 Linting Realm with this PR took 4.52s vs 4.51s on main (0% slower)
📖 Linting Sourcery with this PR took 2.32s vs 2.31s on main (0% slower)
📖 Linting Swift with this PR took 4.53s vs 4.51s on main (0% slower)
📖 Linting VLC with this PR took 1.26s vs 1.25s on main (0% slower)
📖 Linting Wire with this PR took 17.59s vs 17.56s on main (0% slower)
📖 Linting WordPress with this PR took 11.6s vs 11.54s on main (0% slower)

Generated by 🚫 Danger

@Sophrinix
Copy link

what needs to happen to get this merged? Is thing we can do to help on this issue. It would be amazing to have cognitive complexity rule enforcement in this library.

@Sophrinix
Copy link

also why are these warnings being generated here when none of these projects have anything to do with this project?

@mildm8nnered
Copy link
Collaborator

what needs to happen to get this merged? Is thing we can do to help on this issue. It would be amazing to have cognitive complexity rule enforcement in this library.

So it will need to be code reviewed and approved, and then merged. Everyone who contributes to SwiftLint works on a volunteer basis, so it can take a while for people to find time to come back to it. If you look at previously merged PRs, you'll see that it can take a while.

I do have some comments on the PR, but I don't have time right now to take a proper look.

Generally if you can keep the branch clean and without merge conflicts that is good. The changelog can be a bit of a hotspot.

@mildm8nnered
Copy link
Collaborator

also why are these warnings being generated here when none of these projects have anything to do with this project?

So PRs that change any code in SwiftLint (some PRs are excluded but I can't remember the exact basis offhand) are run against a set of popular open source projects, and their violations compared against what main would detect.

This gives a kind of sanity check across a much wider codebase, and inspecting the new violations can be a big clue as to where we might be picking up false alarms, and "fixed" violations can be inspected to see if they really should have been fixed by the changes. In this case, it's a new rule, so you'd only expect new violations.

@@ -16,6 +16,10 @@
[Jordan Rose](https://github.com/jrose-signal)
[SimplyDanny](https://github.com/SimplyDanny)

* Add `Cognitive Complexity Rule`
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you look at previous rule addition changelog entries, they tend to be a bit wordier, and to specify the rule by its identifier. e.g.

* Add new `contrasted_opening_brace` rule that enforces opening
  braces to be on a separate line after the preceding declaration.  
  [SimplyDanny](https://github.com/SimplyDanny)

}

override func visit(_: IfExprSyntax) -> SyntaxVisitorContinueKind {
nesting += 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

It feels like there's quite a lot of repetition in the methods - it would be nice to abstract that way a bit if possible

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

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

Thank you for bringing up this rule, @lorwe!

Evaluating proper implementation of all the rules stated in the white paper was much easier if ComplexityVisitor would be defined in its own file accessible for dedicated testing. In other words, we should first test the complexity calculation on a set of code snippets. Once we are happy with it and find the rules describing Cognitive Complexity being considered, we may embed the visitor in the new SwiftLint rule where we only check for violations according to the computed complexity and the configured limits.

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.

Rule Request: Cognitive Complexity
5 participants