How to check for increase in LOC on commit?
-
02-07-2021 - |
質問
I've been tasked with finding a way of reporting whenever the LOC/file size of certain files in our project increases when someone tries to commit via SVN.
ie. if a file has 26 LOC and a developer increases this, they should be alerted at compile or commit time.
We already use PMD so I was hoping I could make use of a PMD rule to achieve this but having looked in to it I'm not sure if that's possible with PMD.
Any advice or suggestions would be much appreciated.
Thanks
解決
I suggest you take a look at JavaNCSS. It looks to have a sound notion of what a line of code is ... and it appears to be grammar based. You may need to modify / extend / post-process to compare line count changes over time.
UPDATE
Looks like it only supports up to Java 5/6 language syntax.
Having said that, if you only want to do this for "certain files" (i.e. a small number), this strikes me as over-engineering. And if you want to do it for large numbers of files, then one has to wonder if someone (your manager perhaps) has a clinical case of metrics obsession disorder. (This is a delusional disorder where people imagine that software metrics are a valid measure of project progress ...)