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

TrailingComma shows wrong line when AddLines present #737

Open
cyrusdaboo opened this issue May 9, 2024 · 1 comment
Open

TrailingComma shows wrong line when AddLines present #737

cyrusdaboo opened this issue May 9, 2024 · 1 comment

Comments

@cyrusdaboo
Copy link

Use swift-format lint on the following code:

class ABC {
    func method(a: String,
    b: String, c: String, d: String, e: String) -> String {
        let items = [
            "a",
        ]
    }
}

and it gives:

/Users/redacted/Documents/format.swift:7:16: warning: [TrailingComma] remove trailing comma from the last element in single line collection literal
format.swift:2:17: warning: [AddLines] add 1 line break
format.swift:3:1: warning: [Indentation] indent by 4 spaces
format.swift:3:47: warning: [AddLines] add 1 line break

Notice that the TrailingComma message's line number is 7 instead of 5. This seems to occur when there are AddLines messages also present.

Also note that the TrailingComma message shows the full path of the file and not the relative path like the other messages.

@ahoppen
Copy link
Contributor

ahoppen commented May 9, 2024

Synced to Apple’s issue tracker as rdar://127780416

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

2 participants