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

closure_spacing should ignore empty bodies #875

Closed
bsrz opened this issue Nov 10, 2016 · 3 comments
Closed

closure_spacing should ignore empty bodies #875

bsrz opened this issue Nov 10, 2016 · 3 comments

Comments

@bsrz
Copy link

bsrz commented Nov 10, 2016

Triggering example:

class CustomResponse: Response {
        override init() { } // triggers a warning
}

The expectation would be that empty bodies with a single space does not trigger a warning.

@cookednick
Copy link

I can't think of a single real-world use-case where this would be the case. Please correct me if I'm missing something obvious. Your current example doesn't follow convention as typically you'd write:
class CustomResponse: Response { override init() { super.init() } }

@bsrz
Copy link
Author

bsrz commented Nov 14, 2016

Well it's not so much about the init, but about the spacing between the brackets. However, when mocking classes for testing, it often happens that you have to implement a method without a body. Using { } (single space) triggers a warning and you have to use two spaces to suppress it like { }.

It's a super big deal, but figured I'd open an issue anyway so it can be reviewed.

@marcelofabri
Copy link
Collaborator

Another common case is to make existing types conform to a protocol, for example:

protocol ReusableView: class {
    static var reuseIdentifier: String { get }
}

extension ReusableView where Self: UIView {
    static var reuseIdentifier: String {
        return String(describing: self)
    }
}

extension UITableViewCell: ReusableView { }

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

No branches or pull requests

3 participants