Skip to content

Fix false positive in accessibility_label_for_image for SwiftUI Lab…#6594

Open
sutheesh wants to merge 1 commit intorealm:mainfrom
sutheesh:enhancements/6420
Open

Fix false positive in accessibility_label_for_image for SwiftUI Lab…#6594
sutheesh wants to merge 1 commit intorealm:mainfrom
sutheesh:enhancements/6420

Conversation

@sutheesh
Copy link
Copy Markdown

…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
Copy link
Copy Markdown

SwiftLintBot commented Apr 12, 2026

1 Warning
⚠️ This PR may need tests.
76 Messages
📖 Building this branch resulted in a binary size of 27495.77 KiB vs 27495.63 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.8 s vs 0.8 s on main (0% slower).
📖 Linting Alamofire with this PR took 1.06 s vs 1.03 s on main (2% slower).
📖 Linting Brave with this PR took 7.23 s vs 7.21 s on main (0% slower).
📖 Linting DuckDuckGo with this PR took 27.77 s vs 27.84 s on main (0% faster).
📖 Linting Firefox with this PR took 12.12 s vs 12.12 s on main (0% slower).
📖 Linting Kickstarter with this PR took 8.37 s vs 8.4 s on main (0% faster).
📖 Linting Moya with this PR took 0.46 s vs 0.44 s on main (4% slower).
📖 Linting NetNewsWire with this PR took 2.64 s vs 2.6 s on main (1% slower).
📖 Linting Nimble with this PR took 0.72 s vs 0.7 s on main (2% slower).
📖 Linting PocketCasts with this PR took 7.85 s vs 7.72 s on main (1% slower).
📖 Linting Quick with this PR took 0.45 s vs 0.47 s on main (4% faster).
📖 Linting Realm with this PR took 2.99 s vs 2.98 s on main (0% slower).
📖 Linting Sourcery with this PR took 1.88 s vs 1.88 s on main (0% slower).
📖 Linting Swift with this PR took 4.66 s vs 4.66 s on main (0% slower).
📖 Linting SwiftLintPerformanceTests with this PR took 0.31 s vs 0.36 s on main (13% faster).
📖 Linting VLC with this PR took 1.26 s vs 1.22 s on main (3% slower).
📖 Linting Wire with this PR took 18.79 s vs 18.81 s on main (0% faster).
📖 Linting WordPress with this PR took 12.71 s vs 12.68 s on main (0% slower).
📖 This PR fixed a violation in Brave: /ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift:211: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/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/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:133: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/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:67: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:71: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:63: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:78: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/Tabs/TabGrid/TabGridPrivateTabsSettingsView.swift:116: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:118: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:120: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:209: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:285: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:313: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:341: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/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:226: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:238: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:188: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:195: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: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/FavoriteItemView.swift:60: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:70: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 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

…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
@sutheesh sutheesh force-pushed the enhancements/6420 branch from 0ce5790 to 3c52aa9 Compare April 12, 2026 19:10
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

2 participants