Skip to content

closure_spacing autocorrect reports correction but does not fix empty closure { } #6799

Closed

Description

@RobKoch2112

New Issue Checklist

Bug Description

When an empty closure has more than one space between the braces (e.g., { }), running swiftlint --fix reports "Corrected closure_spacing 1 time" but the file content is unchanged. The violation persists on subsequent lint runs.

import Foundation

protocol Foo {
    var bar: () -> Void { get set }
}

extension Foo {
    var bar: () -> Void {
        {  }
    }
}

Note the two spaces in { } on line 9.

$ swiftlint lint --config .swiftlint.yml Example.swift
Example.swift:9:9: warning: Closure Spacing Violation: Closure expressions should have a single space inside each brace (closure_spacing)

$ swiftlint --fix --config .swiftlint.yml Example.swift
Example.swift: Corrected closure_spacing 1 time

$ swiftlint lint --config .swiftlint.yml Example.swift
Example.swift:9:9: warning: Closure Spacing Violation: Closure expressions should have a single space inside each brace (closure_spacing)

Expected: After --fix, { } should become { } (single space), and subsequent lint runs should report no violation.

Actual: The fixer claims success but the file is byte-identical before and after. The violation remains.

This appears to be specific to empty closures used as return values in computed properties.

Environment

  • SwiftLint version: 0.65.0 (also reproduced on 0.63.3)
  • Xcode version: Xcode 16.4 (Build version 16F6)
  • Installation method: SPM build tool plugin / Homebrew
  • Configuration file:
opt_in_rules:
  - closure_spacing

Not using nested configurations.

Activity

  1. added
    bug
    on Jul 3, 2026
  2. self-assigned this
    on Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions