Skip to content

Commit c9fe6e5

Browse files
committed
find dupes order by count
1 parent 22506fe commit c9fe6e5

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 1. Get all .js files recursively
2+
# 2. Look for function patterns
3+
# 3. Group them by the text found
4+
# 4. Filter for groups with more than 1 occurrence
5+
# 5. Sort by duplicate count, lowest to highest
6+
7+
# .\find_dupes_called.ps1 > found_dupes_called.txt
8+
# .\find_dupes_called.ps1 | Out-File -FilePath "found_dupes_called.txt" -Encoding utf8
9+
10+
# Goes up 3 levels to reach HTML-JavaScript-Gaming from tools\shared\powerShell\
11+
# Get the root path (3 levels up)
12+
$rootPath = Resolve-Path "$PSScriptRoot\..\..\..\"
13+
14+
Get-ChildItem -Path $rootPath -Recurse -Filter *.js |
15+
Select-String -Pattern "function\s+[a-zA-Z0-9_]*\(", "[a-zA-Z0-9_]*\s*=\s*function", "[a-zA-Z0-9_]*:\s*function" |
16+
Group-Object Line |
17+
Where-Object { $_.Count -gt 1 } |
18+
Sort-Object Count |
19+
ForEach-Object {
20+
"($($_.Count)) Duplicate line: $($_.Name.Trim())"
21+
22+
$_.Group | ForEach-Object {
23+
# Replace the absolute root path with a single backslash
24+
$relativePath = $_.Path -replace [regex]::Escape($rootPath), ""
25+
" -> Line $($_.LineNumber): \$relativePath"
26+
}
27+
""
28+
}
53.2 KB
Binary file not shown.
53.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)