Skip to content

Fix false positive in accessibility_label_for_image for SwiftUI Lab… - #6594

Merged
SimplyDanny merged 2 commits into
realm:mainfrom
sutheesh:enhancements/6420
Jun 21, 2026
Merged

SimplyDanny merged 2 commits into
realm:mainfrom
sutheesh:enhancements/6420

Conversation

@sutheesh

Copy link
Copy Markdown
Contributor

…el icon closures

Images inside a Label's icon: closure are inherently labeled by the Label's text content and do not need a separate accessibility label. Adds isInsideLabelIconClosure() to detect this pattern via SwiftSyntax and exempts matching images from the rule, with three new non-triggering examples covering systemName, asset name, and uiImage variants.

Fixes #6420

@sutheesh
sutheesh force-pushed the enhancements/6420 branch from 30e5543 to 0ce5790 Compare April 12, 2026 19:06
@SwiftLintBot

SwiftLintBot commented Apr 12, 2026 •

Copy link
Copy Markdown
1 Warning
⚠️ This PR may need tests.
81 Messages
📖 Building this branch resulted in a binary size of 27772.54 KiB vs 27772.38 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.63 s vs 0.65 s on main (3% faster).
📖 Linting Alamofire with this PR took 0.91 s vs 0.93 s on main (2% faster).
📖 Linting Brave with this PR took 6.05 s vs 5.98 s on main (1% slower).
📖 Linting DuckDuckGo with this PR took 25.95 s vs 25.97 s on main (0% faster).
📖 Linting Firefox with this PR took 10.28 s vs 10.35 s on main (0% faster).
📖 Linting Kickstarter with this PR took 7.4 s vs 7.51 s on main (1% faster).
📖 Linting Moya with this PR took 0.37 s vs 0.38 s on main (2% faster).
📖 Linting NetNewsWire with this PR took 2.34 s vs 2.37 s on main (1% faster).
📖 Linting Nimble with this PR took 0.59 s vs 0.57 s on main (3% slower).
📖 Linting PocketCasts with this PR took 6.92 s vs 7.0 s on main (1% faster).
📖 Linting Quick with this PR took 0.4 s vs 0.36 s on main (11% slower).
📖 Linting Realm with this PR took 2.45 s vs 2.5 s on main (1% faster).
📖 Linting Sourcery with this PR took 1.51 s vs 1.52 s on main (0% faster).
📖 Linting Swift with this PR took 4.32 s vs 4.28 s on main (0% slower).
📖 Linting SwiftLintPerformanceTests with this PR took 0.16 s vs 0.16 s on main (0% slower).
📖 Linting VLC with this PR took 1.07 s vs 1.09 s on main (1% faster).
📖 Linting Wire with this PR took 15.13 s vs 15.19 s on main (0% faster).
📖 Linting WordPress with this PR took 10.03 s vs 10.05 s on main (0% faster).
📖 This PR fixed a violation in Brave: /ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift:217:15: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BraveNews/Customize/ChannelLabel.swift:51:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BrowserMenu/CustomizeMenuView.swift:97:19: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BrowserMenu/CustomizeMenuView.swift:132:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BrowserMenu/BrowserMenu.swift:136:15: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BrowserMenu/BrowserMenu.swift:205:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BrowserMenu/BrowserMenu.swift:302:11: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BrowserMenu/BrowserMenu.swift:364:9: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/TransactionConfirmations/PendingTransactionView.swift:294:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/CredentialProviderUI/CredentialDetailView.swift:65:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/CredentialProviderUI/CredentialListView.swift:69:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabGrid/TabGridPrivateTabsSettingsView.swift:61:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabGrid/TabGridPrivateTabsSettingsView.swift:97:19: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabGrid/TabGridPrivateTabsSettingsView.swift:99:19: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabGrid/TabGridPrivateTabsSettingsView.swift:101:19: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/Synced/SyncedTabsView.swift:207:11: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/Synced/SyncedTabsView.swift:281:9: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/Synced/SyncedTabsView.swift:309:9: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/Synced/SyncedTabsView.swift:337:9: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabGrid/TabGridView.swift:716:9: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/QuickView/QuickViewToolbar.swift:35:9: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/History/HistoryView.swift:91:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/History/HistoryView.swift:221:15: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/History/HistoryView.swift:233:15: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/PageContext/AIChatPageContextView.swift:39:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Messages/AIChatIntroMessageView.swift:49:15: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Input/AIChatPromptInputView.swift:121:15: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Input/AIChatPromptInputView.swift:143:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Feedback/AIChatFeedbackToastView.swift:138:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Feedback/AIChatFeedbackToastView.swift:160:11: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Feedback/AIChatFeedbackView.swift:240:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/AIChat/WebUI/AIChatSettingsView.swift:178:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterMultipleProfilesView.swift:30:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/PlaylistUI/PlaylistItemView.swift:86:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Origin/OriginPaywallView.swift:291:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Brave: /ios/brave-ios/Sources/Onboarding/Callouts/OnboardingPlaylistView.swift:396:9: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in DuckDuckGo: /iOS/DuckDuckGo/FeatureFlagsDebugSettings/FeatureFlagsMenuView.swift:48:21: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in DuckDuckGo: /iOS/DuckDuckGo/DebugScreensViewController.swift:55:29: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in DuckDuckGo: /iOS/DuckDuckGo/DebugScreensViewController.swift:203:21: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in DuckDuckGo: /iOS/DuckDuckGo/DebugScreensViewController.swift:211:21: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in DuckDuckGo: /iOS/DuckDuckGo/ReturnToTabCard.swift:341:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in DuckDuckGo: /iOS/DuckDuckGo/FavoriteItemView.swift:61:21: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in DuckDuckGo: /iOS/DuckDuckGo/FavoriteItemView.swift:71:21: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in PocketCasts: /Pocket Casts TV App/UI/MainTabView.swift:117:58: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in PocketCasts: /podcasts/Profile - SwiftUI/Profile/ProfileHeaderView.swift:72:33: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in PocketCasts: /podcasts/Profile - SwiftUI/Profile/ProfileHeaderView.swift:88:33: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in PocketCasts: /Pocket Casts Watch App/UI/Main Page/MenuRow.swift:57:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Wire: /WireUI/Sources/WireMainNavigationUI/Preview/NavigationSplitViewPreview.swift:57:25: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Wire: /WireUI/Sources/WireMainNavigationUI/Preview/NavigationSplitViewPreview.swift:77:25: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Wire: /WireUI/Sources/WireMainNavigationUI/Preview/NavigationSplitViewPreview.swift:97:25: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Wire: /WireMessaging/Sources/WireMessagingUI/WireDrive/Components/ShareLink/ShareLinkPasswordView.swift:180:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Wire: /WireMessaging/Sources/WireMessagingUI/WireDrive/Components/ShareLink/ShareLinkPasswordView.swift:267:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Wire: /WireMessaging/Sources/WireMessagingUI/WireDrive/Components/ShareLink/ShareLinkPasswordView.swift:297:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in Wire: /WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/SortAndFilter/Filter-By Sheets /FilesFilterBy.TypeView.swift:96:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/Plugins/Views/PluginListItemView.swift:41:29: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/Plugins/Views/AddNewPluginView.swift:124:29: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostSettings/Views/Excerpt/PostSettingsGenerateExcerptView.swift:148:21: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostSettings/Views/Excerpt/PostSettingsGenerateExcerptView.swift:196:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationView.swift:50:17: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/System/Sidebar/SidebarViewController.swift:143:25: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/System/Sidebar/SidebarViewController.swift:146:25: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/System/Sidebar/SidebarViewController.swift:270:13: Warning: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)

Generated by 🚫 Danger

@sutheesh
sutheesh force-pushed the enhancements/6420 branch from 0ce5790 to 3c52aa9 Compare April 12, 2026 19:10
@sutheesh

Copy link
Copy Markdown
Contributor Author

@SimplyDanny Can you please help me to review this ?

@SimplyDanny SimplyDanny left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @sutheesh! LGTM except for one remark.

@SimplyDanny SimplyDanny added this to the 0.64.0 milestone Jun 20, 2026
…el icon closures

Images inside a `Label`'s `icon:` closure are inherently labeled by the
Label's text content and do not need a separate accessibility label.
Adds `isInsideLabelIconClosure()` to detect this pattern via SwiftSyntax
and exempts matching images from the rule, with three new non-triggering
examples covering `systemName`, asset name, and `uiImage` variants.

Fixes realm#6420
@SimplyDanny
SimplyDanny enabled auto-merge (squash) June 21, 2026 11:38
@SimplyDanny
SimplyDanny merged commit 6e9eab2 into realm:main Jun 21, 2026
19 checks passed
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.

accessibility_label_for_image: False positive for SwiftUI Label icon closures

3 participants