Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lines of code counts whitespace #17

Open
mattmcnabb opened this issue Jan 10, 2018 · 1 comment
Open

Lines of code counts whitespace #17

mattmcnabb opened this issue Jan 10, 2018 · 1 comment

Comments

@mattmcnabb
Copy link

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.

@Jaykul
Copy link

Jaykul commented Mar 6, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants