Avoid dropping inline comments in control_statement fixes#6545
Avoid dropping inline comments in control_statement fixes#6545theamodhshetty wants to merge 2 commits into
Conversation
Generated by 🚫 Danger |
|
Why not remove the parentheses while keeping the comment as is? |
|
Thanks, that makes sense. I pushed I also checked the same trivia path for Validation rerun:
|
SimplyDanny
left a comment
There was a problem hiding this comment.
Let's have a few more test cases. Quite a few cases are currently not covered.
| ### Bug Fixes | ||
|
|
||
| * Preserve inline comments when `control_statement` removes parentheses during | ||
| `swiftlint --fix`. |
There was a problem hiding this comment.
Please append two spaces to the end of the description. They are required to enforce a line break in the rendered Markdown.
| `swiftlint --fix`. | |
| `swiftlint --fix`. |
| if abc == 1/* && cdf == 2*/ { | ||
| print("Hello, world!") | ||
| } | ||
| """), |
There was a problem hiding this comment.
I wish there were more correction examples. The implementation touches much more constructs than the test examples cover.
Summary
control_statementfrom unwrapping parenthesized conditions when the parentheses contain commentsWhy
swiftlint --fixwas deleting inline comments in cases likeif (abc == 1/* ... */) {}. This change takes the conservative path and skips those corrections instead of applying a destructive rewrite.Testing
Closes #6207