Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $CodeFiles = Get-ChildItem -include *.cs,*.aspx,*.js,*.css,*.master,*.html -exclude *.designer.cs,jquery* -recurse |
- Where-Object { $_.FullName -notmatch '\\(obj|packages|release|debug|plugin-.*)\\' }
- $TotalFiles = $CodeFiles.Count
- $IndividualResults = @()
- $CommentLines = ($CodeFiles | ForEach-Object{
- #Get the comments via regex
- $Comments = ([regex]::matches(
- [IO.File]::ReadAllText($_.FullName),
- '(?sm)^[ \t]*(//[^\n]*|/[*].*?[*]/)'
- ).Value -split '\r?\n') | Where-Object { $_.length -gt 0 }
- #Get the total lines
- $Total = ($_ | select-string .).Count
- #Add to the results table
- $IndividualResults += @{
- File = $_.FullName | Resolve-Path -Relative;
- Comments = $Comments.Count;
- Code = ($Total - $Comments.Count)
- Total = $Total
- }
- Write-Output $Comments
- }).Count
- $TotalLines = ($CodeFiles | select-string .).Count
- $TotalResults = New-Object PSObject -Property @{
- Files = $TotalFiles
- Code = $TotalLines - $CommentLines
- Comments = $CommentLines
- Total = $TotalLines
- }
- Write-Output (Get-Location)
- Write-Output $IndividualResults | % { new-object PSObject -Property $_} | Format-Table File,Code,Comments,Total
- Write-Output $TotalResults | Format-Table Files,Code,Comments,Total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement