A while ago I gave you an advice to create and maintain your own vimfiles. Now, I would advice you to create and maintain your own dotfiles as well. It’s your own environment and tools you use to do your job well.
I will share some command line tools I find useful with focus on ones I use to investigate code issues and stats (some of them depend on Git).
You want to check the project stats and what languages it’s coded in. cloc tool will give you stats about the project, run the following from the project root:
If you’re in a rails project, you can use:
You want to find some trends in the project and discover some hidden issues. Files that frequently change could mean that you have a bad design there that always results in more and more changes. This correlates to the Open/closed principle.
git churn | tail -10 # top 10 files with most changes git churn app # changes in app folder git churn --since='1 month ago' # changes in the last month git churn --email@example.com # changes by author
3. Run command on git revisions
You find your build is failing and you want to find the exact commit where it got broken. Or, you have some performance downgrade that you want to find where it was introduced. With run-command-on-git-revisions you can run a command on a range of revisions:
run-command-on-git-revisions master a0988a0 'rspec spec'
4. God objects
You want to refactor and improve your code, but don’t know where to start? Start by finding the God objects and then go with splitting that code into smaller fine grained objects.
wc -l app/models/*.rb | sort -nr # in app/models find . -name '*.rb' | xargs wc -l | sort -nr | head -10 # all ruby files
You are doing work on the master branch (which btw you shouldn’t, always use a feature branch). With git-divergence you can check how you have divereged from the remote branch and decide if you want to rebase or checkout a feature branch in order to avoid merge commits and/or conflicts. You’ll need
diffstat tool installed for this to work.
# sudo apt-get install diffstat git-divergence # diff between current local and remove git-divergence master feature # diff between any branches
Any command line tools for code stats you want to share?