Notes task for go apps
Very simple — I need a tool to control annotations in my code. I love annotations and think that with good practices they are very useful.
How to use annotations? Very simple, every time you work on some part of a code, and don’t have time to improve it but really want to do that in the nearest future, you drop a comment with a keyword what you think needs to be done here.
Classical annotations are TODO, FIXME, and OPTIMISE, also people love to use BUG and BAD SMELL ones.
RubyOnRails has a cool cli rake task it calls “rake notes”(or rails notes). It scans the source code and prints the comments with annotations. I was using that a lot back in time and was really missing same in GoLang, so I decided to build one myself. And here you go, 1 hour of work, and voila https://github.com/cthulhu/go-notes.
Installations and usage
To get go-notes just run:
go get -u github.com/cthulhu/go-notes
It will fetch the code and automatically build it with your current golang version and place it into your bin directory, so you can access it from any folder.
Usage: go-notes [flags] <Go file or directory> ...
Without options generates all the note types. Defaults are:
// FIXME - call to fix something
// OPTIMIZE - call for a refactoring
// TODO - future plans
-f - FIXME annotations
-o - OPTIMIZE annotations
-t - TODO annotations
-c CUSTOM - custom annotation lable
-format count - output format aggregated counts
-format list - output format list with files and annotations (default)
Jenkins integration with plotting
At our company, we use JenkinsCI for internal projects so it would be nice to integrate go-notes with this CI and plot amount of annotations from branch to branch so we can visually control it.
We will use https://wiki.jenkins.io/display/JENKINS/Plot+Plugin plugin.
Last release of go-notes(since v0.0.3) supports format key so you can define output as CSV with annotation types as a header and counts as a first line. So it will look something like:
This format you can perfectly use with Plot plugin to get a graph like this:
I was also thinking about Github badge with amount of annotations. Same as GoReport or Travic-CI build status. Some thing like:
So users will be able to have visual control over a number of annotations. I really like the idea behind the goreportcard.com service. You can see the code in https://github.com/gojp/goreportcard.
Annotations over some repositories
I did a bit of scanning over the packages and tools i use every day, here are some results:
- https://onsi.github.io/ginkgo/ — TODO: 1
- https://onsi.github.io/gomega/ — TODO: 1
- https://github.com/golang/protobuf — TODO:21
Follow me on Twitter(https://twitter.com/pogrebnyak) for more articles/news/updates about Go programming language.