Skip to content

Commit d6f3c1a

Browse files
committed
Add ignoring directories options
1 parent 9a486dd commit d6f3c1a

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/CodeTopologyBuilder/cloc.fs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
module cloc
1+
[<RequireQualifiedAccess>]
2+
module cloc
23
open FSharp.Data
34

45
type cloc = CsvProvider<"SampleData\cloc.csv">
56
type FileOfCode={fileName:string; language:string; loc:int}
67

7-
let private shouldIgnoreFile(fileName:string)=
8-
let lowerFileName = fileName.ToLower()
9-
lowerFileName.Contains("\\bin\\") ||
10-
lowerFileName.Contains("\\obj\\") ||
11-
lowerFileName.Contains("\\packages\\")
12-
138
let private normalizePath (path:string)=
149
path.Replace("\\", "/")
1510

@@ -18,8 +13,7 @@ let private adjustFilePath filePath normalCheckoutDir =
1813

1914
let getClocData (clocFilePath:string, checkoutDir) =
2015
let normalCheckoutDir = normalizePath checkoutDir
21-
cloc.Load(clocFilePath).Rows
22-
|> Seq.filter (fun x -> shouldIgnoreFile (x.Filename) = false)
16+
cloc.Load(clocFilePath).Rows
2317
|> Seq.map (fun x ->
2418
{ FileOfCode.fileName = adjustFilePath x.Filename normalCheckoutDir
2519
language = x.Language

src/GenerateReport.ps1

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[CmdletBinding()]
22
param(
33
$CheckoutDir,
4-
[Parameter(Mandatory=$true)][ValidateSet('SVN','Git')]$VCS
4+
[Parameter(Mandatory=$true)][ValidateSet('SVN','Git')]$VCS,
5+
[string[]]$DirToExclude
56
)
67

78
$scriptPath = if($PSScriptRoot -eq $null){"."} else {$PSScriptRoot}
@@ -29,7 +30,9 @@ function Get-FilesLOC
2930
}
3031
Write-Verbose "Start colecting LOC statistics"
3132
Remove-Item $OutFilePath -ErrorAction SilentlyContinue
32-
& $clocExePath --by-file --csv --skip-uniqueness --out="$OutFilePath" $CheckoutDir | Write-Verbose
33+
$excludeParam = if ($DirToExclude){"--exclude-dir=$($DirToExclude -join ',')"}else {$null}
34+
Write-Verbose "Exclude $excludeParam"
35+
& $clocExePath --by-file --csv --skip-uniqueness $excludeParam --out="$OutFilePath" $CheckoutDir | Write-Verbose
3336
if(-not(Test-Path $OutFilePath))
3437
{
3538
$PSCmdlet.ThrowTerminatingError("Cannot create LOC statistics file")

0 commit comments

Comments
 (0)