5 ms·
I worked at one company where our build engineer wrote 7500 lines of exceedingly complex Bash code to analyze our source tree and identify "code owners" - i.e.
by Stratoscope 4y ago
I worked at one company where our build engineer wrote 7500 lines of exceedingly complex Bash code to analyze our source tree and identify "code owners" - i.e. whoever had worked the most on each directory and was most familiar with it.
I asked him about it, and he said, "It is a lot of code, but it does a lot. And if I'd written it in C++ it would have been a lot more code than that!"
We were a Python shop.
- IncRnd 4y agoThat sounds like some poor programing in bash. The essence of the problem from what you wrote is something like: display the blame for all lines of all files per folder | sort by name | sum counts by name A single command-line can contain all the bash code, since the necessary tools are all available and can be placed together in a pipeline.
- Stratoscope 4y agoIn all fairness, the Bash code really did quite a bit more than that proverbial one-liner. But much of it wasn't calling and tying together those external tools, it was data analysis code that would have been so much simpler in Python. Plus, being a Python shop, any of us could have maintained a Python version, instead of the one engineer who was truly a Bash wizard. Some common sense and manual work might have been even better: just ask everyone in the company to identify the code areas they were familiar with and manually populate the CODEOWNERS files, instead of spending months on a mostly-failed attempt to automate the whole thing. Or, just teach people how to use git blame! After all, many of us touched many different parts of the code. Git blame would tell you immediately who was familiar with the different bits, at a much more granular level than a CODEOWNERS file in a directory.
- IncRnd 4y agoYou've pointed out several ways things could have been done better in that project. They are all clearly important and hard-won knowledge. But, I have found that one of those is super-duper-extremely important: know when not to program! You can just ask other SMEs (subject matter experts) for the answer!
- jamesfinlayson 4y agoImagine how many lines it would have been in assembly!
- ncmncm 4y agoIf he couldn't do it in 300 lines of Python, C++, or bash, he was incompetent and should have been reassigned. At best. 7500 lines for that is not an asset, it is a liability, regardless of language. At least while he was writing his 7500 lines of bad code, he wasn't doing any other damage. You can throw it out and get somebody else to write a good one in a week.
- masukomi 4y agothat's like... a ~30 line program...maybe take the output of `git ls` group it by directory iterate over the grouped directories passing each file to `git log --follow $1 | git shortlog -sn` sum the numbers next to each name sort the name + number combos within the directory. print the info for each directory.