PSCodeHealth
PSCodeHealth copied to clipboard
Lines of code counts whitespace
When counting lines of code in a script or function, I'd argue that it's most valuable to only consider significant lines of code. It appears that Get-FunctionLinesOfCode is already excluding comments from it's total count, but I think that blank lines should be excluded as well.
Have a look here to see this in practice. If acceptable, I'll submit a PR.
Couldn't you skip re-parsing the file, and just count the unique line numbers that actually have non-comment tokens on them?
($FunctionDefinition.Copy().Findall({$true},$true).Extent | % { $_.StartLineNumber, $_.EndLineNumber } | Sort -Unique -ov Counted).Count