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

Add options to exclude declaration types in VerticalWhitespaceOpeningBracesRule #3400

Closed
SpacyRicochet opened this issue Nov 2, 2020 · 3 comments
Labels
enhancement Ideas for improvements of existing features and rules. wontfix Issues that became stale and were auto-closed by a bot.

Comments

@SpacyRicochet
Copy link

In our team, we prefer a variant to this, but only for computed variables and functions. It would be nice if we could have options to exclude types of declarations.

#1518 (comment)

// ❌ not acceptable
var foo: Foo {
    return Foo()
}

// ❌ not acceptable
func foo() -> Foo {

    return Foo()
}

// ✅ acceptable
protocol FooProvider {

    var foo: Foo { get }

}

// ✅ acceptable
class Foo {

    var foo: Foo {
        Foo()
    }

}
@SpacyRicochet
Copy link
Author

I did try to alter the rule regex in a custom rule to allow for this, but I haven't managed to get one that checks for var and func or for either of them. My regex fu is not good enough for this, apparently. 😬

@jpsim
Copy link
Collaborator

jpsim commented Nov 7, 2020

Ideally we'd avoid using regular expressions altogether for this. They've been useful crutches to allow a lot of rules to be added quickly in SwiftLint's early days, but there are much better tools available to accomplish the same thing, in many cases more reliably.

@jpsim jpsim added the enhancement Ideas for improvements of existing features and rules. label Nov 7, 2020
@stale
Copy link

stale bot commented Jan 6, 2021

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@stale stale bot added the wontfix Issues that became stale and were auto-closed by a bot. label Jan 6, 2021
@stale stale bot closed this as completed Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules. wontfix Issues that became stale and were auto-closed by a bot.
Projects
None yet
Development

No branches or pull requests

2 participants