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

Bug: whitespace added at the end of empty comment lines #319

Closed
eherde opened this issue Nov 17, 2022 · 2 comments · Fixed by #324
Closed

Bug: whitespace added at the end of empty comment lines #319

eherde opened this issue Nov 17, 2022 · 2 comments · Fixed by #324
Labels
bug Something isn't working
Milestone

Comments

@eherde
Copy link

eherde commented Nov 17, 2022

Describe the bug
sqlfmt adds whitespace at the end of empty comment lines. This is inconvenient especially because I have a pre-commit hook that removes whitespace errors.

To Reproduce
Run sqlfmt --diff foo.sql. Output below.

Expected behavior
The tool should output:

1 file passed formatting check.

Actual behavior
It currently outputs:

diff --git a/foo.sql b/foo.sql
index 60c8820694f9..8f350d458d59 100644
--- a/foo.sql
+++ b/foo.sql
@@ -1,7 +1,7 @@
 -- Here is an important comment. It is a comment about a very important and
 -- complicated piece of SQL. It is so complex that it is important that we
 -- can have multiple paragraphs of comments about it.
---
+--
 -- See, here is the very important next paragraph about my code. Any moment
 -- now, you will see the complex query once I am done with this paragraph.
 select 1

The whitespace is more visible in my terminal with git diff.
Screen Shot 2022-11-16 at 17 37 12

Additional context

sqlfmt, version 0.13.0
@tconbeer
Copy link
Owner

Thanks for the report, @eherde!

I agree this is a bug. We are standardizing white space in comments, need to make that conditional on there being content! Should be quite straightforward. I'll squeeze this into v0.14 (next few weeks).

@tconbeer tconbeer added the bug Something isn't working label Nov 17, 2022
@tconbeer tconbeer added this to the v0.14.0 milestone Nov 17, 2022
tconbeer added a commit that referenced this issue Nov 17, 2022
* fix #319: no trailing whitespace on empty comments

* chore: update primer refs

* chore: add unit test
@tconbeer
Copy link
Owner

@eherde This patch has been merged to main. Thanks again for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants