-
Notifications
You must be signed in to change notification settings - Fork 195
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
Remove empty haddocks and remove empty comments. #1459
base: master
Are you sure you want to change the base?
Remove empty haddocks and remove empty comments. #1459
Conversation
No idea on the refactor thing - @zliu41 is the expert there. Can you turn your test script into something that runs via the |
330fa93
to
a6dcef7
Compare
Thanks for the suggestion @ndmitchell, I've done that now. |
6c6e49e
to
0026c5a
Compare
- Only those not followed by something. - Add haddocks. - Use GHC's isPointRealSpan - Satisfy -Wprepositive-qualified-module - Use isOneLineSpan
- Convert .hs into a .test - Split empty line comment tests - Add test for spaced single line comments
- Rename comment to idea - Add EmptyComment type
- Partition pragmas - Partition haddocks
7c419c5
to
cf7d1ee
Compare
cf7d1ee
to
d5ffa47
Compare
I note this is still in draft - is there something else you are hoping to do here before I take a look? |
Thanks @ndmitchell but this is not ready for review (and apologies for reworking it on this PR branch and not on another branch). I had an initial implementation that detected simple empty comments, like these;
As I did more testing I found more types of empty comment that I'd like to include, doctest comments in particular;
If an otherwise empty haddock comment includes a empty doctest comment then which new HLint suggestion should take precedence or should I report both?
I'm also considering reporting leading or trailing blank lines in haddocks. For instance, in the Agda source there are many trailing blank lines in its haddocks.
Should there be separate HLint suggestions for trimming leading or trailing blank lines? Should the same go for trimming a run of blank lines down to single blank line in otherwise non-empty comments? I'm in the process of redoing the implementation to first partition comment types and then do the detection as before. In the earlier implementation I processed single line comments one at a time but I think I could provide more nuanced empty comment detection if I treated a run of comments (with a haddock leader) like a multi-line haddock comment. |
Can we suggest removing empty comments and removing empty haddocks? I've seen examples of these littering code, like the following:
I had a crack at doing this.
cabal run hlint -- --refactor tests/empty-comment-test.hs
the comments are removed but single line comments are replaced by an empty line. I'd really like to remove the whole line. Is there a way to do that? I triedadvanceSrcLoc (realSrcSpanEnd realSpan) '\n'
for the refactor span but this didn't work as I'd hoped.tests/empty-comment-test.hs
into tests.