Sure, a precise definition of how to count LOC is needed as explained in the Wikipedia article Source lines of code.
If you have a good understanding of your coding standards you could perhaps code a script to count LOC for your projects, but why not use a tool made for this exact purpose ? You might even be able to integrate such a tool with UE as a User Tool.
I have no experience with tools for counting LOC - but these came out on top in a google search: