Hacker News new | ask | show | jobs
by laumars 4041 days ago
This functionality is already built into every major OS and this new tool isn't any easier to use than the existing ones:

Linux / UNIX:

  grep -n TODO *.js
Windows:

  find /n "TODO" *.js
2 comments

This library is also doing regex matching, so that you don't have to worry about matches that exist outside of comments...

But like you said...you could always use fgrep (and most of us probably don't have "TODO" outside of comments anyways).

grep supports regular expressions as well (hence it's name: http://en.wikipedia.org/wiki/Grep). In fact GNU grep even has support for PCRE.

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

  alert('TODO: this feature hasn't been implemented yet')
but in those instances you'd want the source code captured as well).
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.

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.

Probably never. False positives is just a nice catch-phrase ;) But I don't presume to know other people's naming patterns
If you have TODO outside of comments which are false positives, you need to see those, and weed them out along with the true TODO items.

This TODO scanner project is completely, utterly, pointless.

There is no need for your second line. Your first line is a valid, relevant opinion. The second one has no use but to belittle the OP (or anyone else who has written a TODO scanner). You're being a dick, and missing the forest for the trees while you're at it. This project can be integrated into a larger gulp workflow, for example. It also has the ability to write the output to custom formats.
I see, I can build a cloud-powered dashboard to give my mobile workforce a semantically-enhanced visibility into the proliferation of TODO comments throughout the enterprise, integrated into the social networking applications they already use.

TODO comments could automatically be turned into action items, against the developer who introduced them (git blame!)

The software could be intelligent enough to uncover relationships among the TODO's, and schedule a meeting for specific subsets of TODO's, calling in all the relevant peo^H^H^H stake holders.

;) I'm in no way offended. I guess kazinator is spending his time much better than me. But anyway, if anyone is more comfortable using CLI (or any IDE that provides this) with grep/ack/ag/pt and that solves parsing todos for him, that's great. I would only use Leasot if you need easy integration with other tools (think JSONs/XML), want to trim down false positives (such as variable names, strings etc...).

There are probably other use cases, but overall, if cli regex works great for you, stick with it.

Regarding if Leasot is pointless or not, well everyone is entitled to their own opinion (kazinator). In the greater sense I guess the world needs more todo doers than todo parsers ;)

You probably want fgrep.
fgrep / grep -F only really comes into it's own if you have regular expression patterns that need to be matched as plain strings. "TODO" is purely alpha characters so regular grep is fine.
Did not know that. Thank you.
What did you think regular grep did, then?