Show HN: Parse and output TODOs and FIXMEs from comments in your files
github.com
github.com
It works great as a code review tool, too. Agree on a marker, add review comments to code, commit to source control and tell your team mate about it. It's just about at-your-fingertips as diffs-with-comments tools (like github PRs), and way lighter on the tooling. You also see all the context, not just the changed lines. Eg:
// REVIEW(me): This is getting big, maybe split into two classes?
In smaller teams (say, <5 people on a single shared codebase) I've found this to work remarkably well.My first reaction was saying we already have that in our rails project using `rake notes`. As he mentioned, the rake task is very slow, though. It will also ignore a lot of our code which is not rails specific.
Thinking about it twice, I realized: this should be hooked to git. This allows very fast lookup and will ensure we do not search in not commited and thus irrelevant files, like logs.
I came up with this alias for git:
todo = grep -E 'FIXME|TODO'
Formatting is nowhere near as pleasant as Leasot or `rake notes`, but it's blazing fast and relevant.Anyway, thanks for having made us think about that :)
ag "(TODO|FIXME)" $> grep -Hn TODO test.js
test.js:241:TODO ...1. Fun to build. 2. Output looks prettier. 3. Easier to add more syntactic stuff as edge cases for different languages are factored in. Won't be too hard to extend it for github issues, for example.
Since there would be very few cases of partial matches of "TODO" I think grep would still be much faster.
2. $ alias grep="grep --color"
3. it would be even easier to extend grep via pipes. Plus pipes are langauge agnostic where as extending this tool requires knowledge of Python
As a personal project, this is fine. But I really don't see the point in anyone else using it when it's slower than existing tools, no more user friendly, requires more dependancies, and isn't part of the default install like grep and find (Windows CLI) are. Plus this tool doesn't even support all instances where a TODO might appear (https://github.com/pgilad/leasot#comment-format) nor all programming languages (https://github.com/pgilad/leasot#supported-languages) like grep and find do.
Ah yes, my mistake. Though being written in Javascript makes it even worse for requiring dependencies as at least Python ships with most distros default install.
> Regarding pretty output - that could definitely be argued, but Leasot also allows for different reporters, say you want the output in JSON/XML for an external tool. That is extendable, whereas grep over regex in CLI is fast & powerful but not as flexible
I'd already addressed that point. UNIX pipes allow you to extend grep using any language (including Javascript / node.js) you want. Leasot if only extendible if you already know Javascript and node.js. Plus there are plenty of CLI tools available that can read list input from STDIN and spit out JSON or XML - so you don't even need to learn how to program to convert data files.
I've lost count of the number of times I've seen people write multi-functional programs to solve problems that would have been quicker (both in development time, and execution) to pipe a couple of existing programs together. Heck, I've even fallen into this trap myself before.
Also, you run into problems with strings which might be a false positive
1. View -> Task List
2. At the top of the task list click the drop-down that is by default set to "User Tasks" and choose "Comments."
You can also customize the trigger words[1]. I very rarely use the feature myself as failing unit tests are far superior when compared to TODOs.
You can also configure the text for each tag (TODO, FIXME, etc.) as well as the priority.
Now what happens when you want the output in different formats? I had a person contacting me for exporting as xml since he wants to plug it in for a CI (jenkins). What if you want a JSON for your own tool?
Leasot is far from the perfect solution to TODOs, but if your use case requires anything other than simple regex, you will run into the same issues that Leasot tries to solve.
As far as speed, in my work project, parsing 552 javascript files takes around 0.2s on my mac. Some of these files being really big.
In short, a cool tool, which I hope you had fun creating to fill your needs, but it's not something I could personally justify using at the moment. My lint tools (for Python) and `godoc` already alert me to "XXX" and "TODO" comments, letting me see them as part of my normal programming flow.
I wouldn't expend too much effort trying to convince others of it's utility - you'll get frustrated. Instead, let the tool's utility speak for itself (if its useful to you, it will also be useful to someone else), and move on and create more useful tools.
For ST2: https://github.com/SublimeLinter/SublimeLinter-for-ST2#subli...
For ST3: https://github.com/SublimeLinter/SublimeLinter-annotations
It uses git grep for grepping/colouring the output and sed to remove prefixed whitespace.
If CLI regex matching (grep, ag, git grep, pt, ack...) works for you, I would stick with it ;)
the watson[1] gem (for ruby) has a nice feature list you could go off of. leasot + some of those features might be more suitable for people who want to stay in npmland
In github issues you mean exporting a TODO to a github issue? If so, I don't think that belongs in Leasot, but rather an external tool for creating/manipulating Github issues (And I'm sure that kind of tool exists).
In a production codebase, you are absolutely correct, you should standardize these items into a ticket manager.
Then it's a simple matter of grepping through the codebase for "XXX" and "TODO" and implementing the changes.
Even when starting from scratch, my usual flow is to implement the top level logic using stubs (commented with "XXX"), then go back and fill in the logic from there.
Linux / UNIX:
grep -n TODO *.js
Windows: find /n "TODO" *.jsBut like you said...you could always use fgrep (and most of us probably don't have "TODO" outside of comments anyways).
This TODO scanner project is completely, utterly, pointless.
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 ;)
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.
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).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.
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.