Re:Show HN: Parse and output TODOs and FIXMEs from comments ...
by pgilad on Monday May 25, 2015 @11:19AM
(#9600365)
Yep, truly avoiding false positives and capturing all todos you would need to really parse the source code (perhaps creating an AST or lexical parsing).
Even if you build that tool (which handles many languages) - it has an extra headache cost with the parsing time, which might be really slow for large projects.
I actually started Leasot with Javascript AST checking which never misses TODOS but is very hard to extend to other languages, as well as parsing speed was a magnitude slower.
Re:Show HN: Parse and output TODOs and FIXMEs from comments ...
by laumars on Monday May 25, 2015 @11:24AM
(#9600382)
Just out of interest, how often do you find yourself using "TODO" as a variable name or elsewhere in your code?
This isn't a dig, it's just something I've genuinely never stumbled across in 2 decades of programming so wondered if there's a culture out there I've missed.
However it should be noted that regex isn't the right tool for parsing source code to begin with. There could be instances in that code where false positives are matched. And there are already known instances where positives are missed (namely "//" comments). So if you really want to exclude anything that isn't a comment then the only accurate way to do so would be full source code parsing. Failing that, it's better to match all instances since "TODO" generally isn't a string that occurs frequently outside of comments (unless it's a visual prompt to the user, eg
but in those instances you'd want the source code captured as well).