How large is your codebase?
Tags: todayilearned, bash, git
Published: 2020-03-27 06:42:43

## The questions

So, today something sparked my curiosity to know _just how large is the codebase I work with at my job_ ??

And along with that: _Is there a way I can measure that?_

## One approach

In retrospect, I've grown with the company... working with teams as they are created to create new parts of the platform and new applications which some are exposed to external users and others remain for internal use only.

I looked for the repos I have worked on so far and found that it was at least 10 different UI repos from our [microservice](https://microservices.io/) architecture, and that out of those maybe 5 or 6 I pushed code for their groundwork, including the component library we have in there and a starter that we use to spin up new repos.

Nice! Axel 1 - 0 Imposter syndrome 

## What about being more specific?

Then I thought: "All right, but they could be real small repos with apps which are not that complex or business logic that is too simple". Spoiler alert: nope, some have really heavy logic stuff that I am actually very proud of, like the [migration I worked on last year](https://dev.to/ackzell/a-tale-of-a-migration-46d1).

Pretty sure somebody already said that our worst enemy lies within ourselves. 2 points for me 🎉!

## So, how _large_ would the codebase I am working with really be?

Still hard to answer that using cold numbers, but!

I figured if there was a way I could count the _Lines Of Code_ for some of those repos, I would probably feel like I have a better idea and can finally go to bed 😛.

Stack Overflow to the rescue... and I found [this answer](https://stackoverflow.com/a/4822516/1691580) to determine an approximate of how many lines of code I had. 

So, fired up my terminal and on the repos I remembered I worked on I ran:
```
$ wc -l $(git ls-files | grep 'source/')
```
Please note that this is specifically grepping (is that a verb?) for the source folder, meaning there are no files in the dependencies listed (npm packages or bower stuff or whatever).

So we have in no particular order (commas added for readability) the following results for a few repos: 

```
31,461 total
17,371 total
29,263 total
168 total
2,827 total
11,178 total
1,501,180 total
```

## Go to sleep already!

Just one more thing...
How would my contribution to those repos look like? Because sure, those could be (or not) large numbers, but how much have I really contributed to that so far? (There is also some good in questioning one self, I'm sure, to keep you real).

I went and checked the contributions per user on said repos and found (not in the same order I listed the previous, so no direct correlation there):

```
ackzell
120 commits  30,648 ++  6,652 --

ackzell
162 commits  16,106 ++  9,009 --

ackzell
13 commits  617 ++  173 --

ackzell
125 commits  20,977 ++  9,926 --

ackzell
23 commits  51,816 ++  48,318 --

ackzell
2 commits  206 ++  197 --

ackzell
16 commits  959 ++  750 --
```

Seems like I've written (and removed) a good chunk of that platform, and I am so very proud of my work. 

So next time I am prompted to answer myself "how large is the codebase you are working with?" I will at least have a vague idea 😬)

Cheers!