Skip to content

Add allow_compact_empty_blocks option to no_empty_block rule - #6840

Merged
SimplyDanny merged 1 commit into
realm:mainfrom
arimu1:feat/no-empty-block-allow-compact-empty-blocks
Jul 27, 2026
Merged

SimplyDanny merged 1 commit into
realm:mainfrom
arimu1:feat/no-empty-block-allow-compact-empty-blocks

Conversation

@arimu1

@arimu1 arimu1 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add allow_compact_empty_blocks boolean configuration option to no_empty_block (defaults to false).
  • When enabled, compact empty blocks written as {} are allowed, while empty blocks with whitespace or newlines between the braces are still flagged.
  • Update rule examples, configuration tests, default rule configurations, and CHANGELOG.

Fixes #6839

Test plan

  • swift build --target SwiftLintBuiltInRules passes locally
  • swift test --filter NoEmptyBlock — blocked locally (no full Xcode; swift test fails on missing XCTest module)
  • xcodebuild -scheme swiftlint test -destination 'platform=macOS' — blocked locally (only Command Line Tools installed)
  • CI

@SwiftLintBot

SwiftLintBot commented Jul 25, 2026 •

Copy link
Copy Markdown
19 Messages
📖 Building this branch resulted in a binary size of 28373.98 KiB vs 28357.8 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.94 s vs 0.92 s on main (2% slower).
📖 Linting Brave with this PR took 5.97 s vs 6.0 s on main (0% faster).
📖 Linting DuckDuckGo with this PR took 26.34 s vs 26.38 s on main (0% faster).
📖 Linting Firefox with this PR took 10.56 s vs 10.54 s on main (0% slower).
📖 Linting Kickstarter with this PR took 7.17 s vs 7.23 s on main (0% faster).
📖 Linting Moya with this PR took 0.34 s vs 0.37 s on main (8% faster).
📖 Linting NetNewsWire with this PR took 2.33 s vs 2.39 s on main (2% faster).
📖 Linting Nimble with this PR took 0.6 s vs 0.56 s on main (7% slower).
📖 Linting PocketCasts with this PR took 6.95 s vs 6.94 s on main (0% slower).
📖 Linting Quick with this PR took 0.34 s vs 0.36 s on main (5% faster).
📖 Linting Realm with this PR took 2.43 s vs 2.42 s on main (0% slower).
📖 Linting Sourcery with this PR took 1.5 s vs 1.46 s on main (2% slower).
📖 Linting Swift with this PR took 4.26 s vs 4.28 s on main (0% faster).
📖 Linting SwiftLintPerformanceTests with this PR took 0.16 s vs 0.16 s on main (0% slower).
📖 Linting VLC with this PR took 1.18 s vs 1.17 s on main (0% slower).
📖 Linting Wire with this PR took 15.27 s vs 15.35 s on main (0% faster).
📖 Linting WordPress with this PR took 9.73 s vs 9.76 s on main (0% faster).

Generated by 🚫 Danger

Allow empty blocks written compactly as `{}` while still flagging empty
blocks with whitespace or newlines between the braces.

Fixes realm#6839
@arimu1
arimu1 force-pushed the feat/no-empty-block-allow-compact-empty-blocks branch from b2c7ef9 to 60a5be6 Compare July 25, 2026 02:25

@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.

LGTM! Thanks @arimu1!

@SimplyDanny
SimplyDanny enabled auto-merge (squash) July 27, 2026 16:17
@SimplyDanny
SimplyDanny merged commit fc5f99e into realm:main Jul 27, 2026
30 of 31 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.

Add allow_compact_empty_blocks boolean option to no_empty_block

3 participants