Counting Lines of Code with GitHub Linguist and Bash
If you’re using GitHub Linguist to analyze your project’s code, you may want to take a closer look and see how many lines each individual file contains. GitHub Linguist provides a useful breakdown of the languages and files, but not an easy way to get line counts for each file. Let’s dive into how you can achieve this using a combination of GitHub Linguist, jq
, and some classic Bash commands.
Analyzing lines of code (LOC) per file is a useful metric to:
- Assess Complexity: Identifying files with excessive lines of code might highlight areas that could benefit from refactoring.
- Identify Hotspots: Knowing where most of the code resides helps focus efforts for documentation or optimization.
- Track Growth: Monitoring LOC helps gauge how your project is evolving over time.