-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Lint idea: Comments that contain TODO
or FIXME
#1267
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
Comments
That's a tricky one, Clippy does not see non-doc comments. |
We should however be able to get the full source code for the crate by walking the source map. That may or may not include comments, however. |
We'd have to then parse that to get all the comments somehow. Looks like |
I did not say that it was easy. Just that it was probably possible. 😄 |
And I did not say it was impossible. Just that is was E-hard 😄 |
Oh geez! I did not even realize that :) eeeeeep. |
BTW, it looks like rustfmt can report those: https://github.com/rust-lang-nursery/rustfmt/blob/23f01eddacccf4c9b871b0fd84d4344fd67bf668/src/config.rs#L386-L389. |
This is one feature I like from eslint and I agree it would be great to have. In eslint the rule is called no-warning-comments, in case any of you may derive some ideas from it. |
I don't think we should keep this open since rustfmt already can report TODOs and is configurable about it. |
Fair enough, I guess you're set on this. The reason I was hoping to see it in clippy was because it would indirectly integrate with existing editor integration for reporting errors/warnings/notes in-editor. I have rustfmt integration in my editor (emacs) but the extent to which I use it is typically a keybind that simply formats the current file (or even auto trigger it on-save). For example since eslint also supports this feature, TODOs, FIXMEs, and any other marker I wish to define will show up in the editor as a warning (or error if I set it to be an error) and I'll also see it in the list of errors/warnings in the editor. Using rustfmt for this purpose will either require each editor to add support for it specifically or we'll need to run it from the terminal in a way that is not as ergonomic. To be honest it feels pretty weird that it's implemented in rustfmt at all, as I tend to associate left-over TODOs/FIXMEs with linting than code style formatting. I looked at the rest of the options rustfmt has and these two stand out as drastically different from the rest in that the majority of the options affect transformations on the code (which is why it's normal to just have a bind or on-file-save format the code) and these two are for reporting to the user that these items were found. |
I personally don't see this as a blocker, because AFAIK, all major IDEs provide this capability either directly or through a popular plugin. IntelliJ highlights TODOs and FIXMEs and marks them on the scrollbar, Sublime Text's sublime-linter plugin has a plugin for annotations which covers this, and Atom certainly has something like this too, although I don't know the name of it off hand. I think it would be nice to have clippy report this with its other warnings, but it seems like it would provide too little benefit compared to the difficulty of the task and the code complexity that would be added to clippy. |
This has now been removed from rustfmt and implemented in clippy. |
That refers to the |
Is there any possibility of re-opening this now that |
Adding lint by |
@lomirus Are you suggesting that as an alternative to linting against comments? |
@BatmanAoD Yes. But Rust does not currently support this syntax, and I'm not sure if that's beyond the scope of this issue or clippy. |
Hm, I don't really see how that would be preferable to implementing the originally-requested feature. |
Hi! This paper gave me some ideas for some lints. Here's one:
Warn for any usage of
TODO
orFIXME
in a comment!This could be any comment anywhere, or that paper pointed out that these comments in error handling code was a sign of code that could potentially cause bugs down the line.
The text was updated successfully, but these errors were encountered: