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

change excludingSyntaxKinds for VerticalWhitespaceBetweenCasesRule.swift #5612

Closed
ilendemli opened this issue May 29, 2024 · 4 comments · Fixed by #5628
Closed

change excludingSyntaxKinds for VerticalWhitespaceBetweenCasesRule.swift #5612

ilendemli opened this issue May 29, 2024 · 4 comments · Fixed by #5628

Comments

@ilendemli
Copy link
Contributor

ilendemli commented May 29, 2024

Hi I was applying this ruleset and saw it skip some parts of my code

Regarding this:

return match(pattern: pattern, excludingSyntaxKinds: SyntaxKind.commentAndStringKinds)

I think it should also apply for String cases and only exclude SyntaxKind.commentKinds

@SimplyDanny
Copy link
Collaborator

What's an example that would work correctly with this change?

@ilendemli
Copy link
Contributor Author

Currently running the fix argument against a file such as:

import Foundation

enum TestCase: String {
    case one = "1"
    case two = "2"
    case three = "3"

    var caseToString: String {
        switch self {
        case .one:
            return "one"
        case .two:
            return "two"
        case .three:
            return "three"
        }
    }

    var rawToString: String {
        switch rawValue {
        case "1":
            return "one"
        case "2":
            return "two"
        case "3":
            return "three"
        }
    }
}

does not change anything. With the above change to only exclude SyntaxKind.commentKinds the file gets corrected to:

import Foundation

enum TestCase: String {
    case one = "1"
    case two = "2"
    case three = "3"

    var caseToString: String {
        switch self {
        case .one:
            return "one"

        case .two:
            return "two"

        case .three:
            return "three"
        }
    }

    var rawToString: String {
        switch rawValue {
        case "1":
            return "one"

        case "2":
            return "two"

        case "3":
            return "three"
        }
    }
}

@SimplyDanny
Copy link
Collaborator

Would you like to open a PR to fix this, @ilendemli?

@ilendemli
Copy link
Contributor Author

@SimplyDanny #5628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants