Skip to content

Commit ff37ad2

Browse files
jbamptonpaulirwin
andauthored
misc: fix typos (apache#1308)
* misc: fix typos General clean up * Add script to prune suppressions, remove old psake file --------- Co-authored-by: Paul Irwin <paulirwin@gmail.com>
1 parent 774bd81 commit ff37ad2

10 files changed

Lines changed: 116 additions & 2283 deletions

File tree

.build/azure-templates/publish-test-results-for-test-projects.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ steps:
7474
- template: publish-test-results.yml
7575
parameters:
7676
testProjectName: 'Lucene.Net.Tests.CodeAnalysis'
77-
framework: 'net8.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
77+
framework: 'net8.0' # Since conditions are not supported for templates, we check for the file existence within publish-test-results.yml
7878
vsTestPlatform: '${{ parameters.vsTestPlatform }}'
7979
osName: '${{ parameters.osName }}'
8080
testResultsFormat: '${{ parameters.testResultsFormat }}'

.build/psake/en-US/psake.psm1-help.xml.old

Lines changed: 0 additions & 2265 deletions
This file was deleted.

.build/psake/public/Assert.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ function Assert {
2020
.EXAMPLE
2121
C:\PS>Assert ( ($i % 2) -eq 0 ) "$i is not an even number"
2222
23-
This exmaple may throw an exception if $i is not an even number
23+
This example may throw an exception if $i is not an even number
2424
2525
Note:
26-
It might be necessary to wrap the condition with paranthesis to force PS to evaluate the condition
26+
It might be necessary to wrap the condition with parenthesis to force PS to evaluate the condition
2727
so that a boolean value is calculated and passed into the 'conditionToCheck' parameter.
2828
2929
Example:
3030
Assert 1 -eq 2 "1 doesn't equal 2"
3131
32-
PS will pass 1 into the condtionToCheck variable and PS will look for a parameter called "eq" and
32+
PS will pass 1 into the conditionToCheck variable and PS will look for a parameter called "eq" and
3333
throw an exception with the following message "A parameter cannot be found that matches parameter name 'eq'"
3434
3535
The solution is to wrap the condition in () so that PS will evaluate it first.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env pwsh
2+
<#
3+
.SYNOPSIS
4+
Reports (and optionally removes) entries in codespell.txt that codespell no longer flags.
5+
6+
.DESCRIPTION
7+
Codespell has no built-in way to detect unused entries in an ignore-words file.
8+
This script runs codespell against the repo with NO ignore-words file, collects the
9+
set of words it flags, and reports any suppression in codespell.txt that is not in
10+
that set (i.e., the suppression is no longer needed).
11+
12+
The pre-commit hook invocation in .pre-commit-config.yaml is mirrored here so the
13+
scan covers the same files codespell would normally see.
14+
15+
.PARAMETER Apply
16+
Rewrite codespell.txt with the unused entries removed. Without this switch the
17+
script only reports.
18+
19+
.PARAMETER CodespellCommand
20+
Override the codespell executable (default: "codespell").
21+
#>
22+
[CmdletBinding()]
23+
param(
24+
[switch]$Apply,
25+
[string]$CodespellCommand = 'codespell'
26+
)
27+
28+
$ErrorActionPreference = 'Stop'
29+
30+
$repoRoot = (& git -C $PSScriptRoot rev-parse --show-toplevel).Trim()
31+
$suppressionsFile = Join-Path $repoRoot '.github/linters/codespell.txt'
32+
33+
if (-not (Test-Path $suppressionsFile)) {
34+
throw "Suppressions file not found: $suppressionsFile"
35+
}
36+
37+
# Must match the `exclude:` regex for the codespell hook in .pre-commit-config.yaml.
38+
$excludeRegex = '^src/Lucene\.Net\.Analysis\.Common/Analysis/../.*\.rslp$|^.*Lucene\.Net\.Tests.*$'
39+
40+
$suppressions = Get-Content -LiteralPath $suppressionsFile |
41+
Where-Object { $_ -ne '' }
42+
43+
Write-Host "Loaded $($suppressions.Count) suppression(s) from $suppressionsFile"
44+
Write-Host "Enumerating git-tracked files (to match pre-commit's view of the repo)..."
45+
46+
# pre-commit only feeds tracked files to codespell; running codespell directly would
47+
# also walk bin/, obj/, and other gitignored output. Drive it with `git ls-files`
48+
# so the two scans cover the same file set.
49+
Push-Location $repoRoot
50+
try {
51+
$trackedFiles = & git ls-files
52+
Write-Host "Running codespell on $($trackedFiles.Count) tracked file(s) with NO ignore list..."
53+
54+
# Write the file list to a temp argsfile and pass it with codespell's "@PATH"
55+
# syntax. This avoids OS argv length limits on large file lists.
56+
$argsFile = New-TemporaryFile
57+
try {
58+
Set-Content -LiteralPath $argsFile -Value $trackedFiles -Encoding utf8
59+
# We don't care about exit code: a non-zero exit just means it found
60+
# misspellings, which is exactly what we want.
61+
$rawOutput = & $CodespellCommand "@$argsFile" 2>&1
62+
}
63+
finally {
64+
Remove-Item -LiteralPath $argsFile -ErrorAction SilentlyContinue
65+
}
66+
}
67+
finally {
68+
Pop-Location
69+
}
70+
71+
# Codespell output format: "<path>:<line>: <flagged> ==> <suggestion>"
72+
# Filter out paths that match the pre-commit exclude regex, then extract the flagged word.
73+
$flagged = New-Object System.Collections.Generic.HashSet[string]
74+
foreach ($line in $rawOutput) {
75+
if ($line -notmatch '^(?<path>[^:]+):\d+:\s+(?<word>\S+)\s+==>') { continue }
76+
$path = $Matches['path']
77+
if ($path -match $excludeRegex) { continue }
78+
# Suppressions are case-sensitive and matched against the dictionary entry's case.
79+
[void]$flagged.Add($Matches['word'].ToLowerInvariant())
80+
}
81+
82+
Write-Host "Codespell flagged $($flagged.Count) distinct word(s) (after applying exclude regex)."
83+
84+
$unused = $suppressions | Where-Object { -not $flagged.Contains($_.ToLowerInvariant()) }
85+
86+
if (-not $unused) {
87+
Write-Host "No unused suppressions found. codespell.txt is clean." -ForegroundColor Green
88+
return
89+
}
90+
91+
Write-Host ""
92+
Write-Host "Unused suppressions ($($unused.Count)):" -ForegroundColor Yellow
93+
$unused | ForEach-Object { Write-Host " $_" }
94+
95+
if ($Apply) {
96+
$keep = $suppressions | Where-Object { $flagged.Contains($_.ToLowerInvariant()) }
97+
# Preserve trailing newline that codespell.txt currently has.
98+
Set-Content -LiteralPath $suppressionsFile -Value $keep -Encoding utf8
99+
Write-Host ""
100+
Write-Host "Removed $($unused.Count) unused entr$(if ($unused.Count -eq 1) { 'y' } else { 'ies' }) from codespell.txt." -ForegroundColor Green
101+
} else {
102+
Write-Host ""
103+
Write-Host "Re-run with -Apply to remove these from codespell.txt."
104+
exit 1
105+
}

.github/linters/codespell.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ compatibity
7474
compatiblity
7575
completly
7676
concret
77-
condtions
7877
confguration
7978
conjuction
8079
conjuntions
@@ -127,9 +126,6 @@ entend
127126
equest
128127
euclidian
129128
everytime
130-
execeptions
131-
exmaple
132-
explicitely
133129
explicity
134130
faild
135131
failue
@@ -207,7 +203,6 @@ kake
207203
ket
208204
lama
209205
lief
210-
lien
211206
loner
212207
longwinded
213208
maching
@@ -285,8 +280,6 @@ plaforms
285280
pluse
286281
pont
287282
posin
288-
postion
289-
postions
290283
pre-pended
291284
pres
292285
prevend

src/Lucene.Net.Highlighter/Highlight/WeightedSpanTerm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public WeightedSpanTerm(float weight, string term, bool positionSensitive)
4444
/// <summary>
4545
/// Checks to see if this term is valid at <paramref name="position"/>.
4646
/// </summary>
47-
/// <param name="position">to check against valid term postions</param>
47+
/// <param name="position">to check against valid term positions</param>
4848
/// <returns>true iff this term is a hit at this position</returns>
4949
public virtual bool CheckPosition(int position)
5050
{

src/Lucene.Net.Replicator/Support/Http/Abstractions/IReplicationRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ namespace Lucene.Net.Replicator.Http.Abstractions
2727
public interface IReplicationRequest
2828
{
2929
/// <summary>
30-
/// Provides the requested path which mapps to a replication operation.
30+
/// Provides the requested path which maps to a replication operation.
3131
/// </summary>
3232
string Path { get; }
3333

3434
/// <summary>
3535
/// Returns the requested query parameter or null if not present.
3636
/// </summary>
3737
/// <remarks>
38-
/// May though execeptions if the same parameter is provided multiple times, consult the documentation for the specific implementation.
38+
/// May throw exceptions if the same parameter is provided multiple times, consult the documentation for the specific implementation.
3939
/// </remarks>
4040
/// <param name="name">the name of the requested parameter</param>
4141
/// <returns>the value of the requested parameter or null if not present</returns>

src/Lucene.Net.Tests/Search/TestPositionIncrement.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public virtual void TestSetPosition()
8787
hits = searcher.Search(q, null, 1000).ScoreDocs;
8888
Assert.AreEqual(0, hits.Length);
8989

90-
// same as previous, just specify positions explicitely.
90+
// same as previous, just specify positions explicitly.
9191
q = new PhraseQuery();
9292
q.Add(new Term("field", "1"), 0);
9393
q.Add(new Term("field", "2"), 1);
@@ -128,7 +128,7 @@ public virtual void TestSetPosition()
128128
hits = searcher.Search(q, null, 1000).ScoreDocs;
129129
Assert.AreEqual(0, hits.Length);
130130

131-
// multi-phrase query should succed for non existing searched term
131+
// multi-phrase query should succeed for non existing searched term
132132
// because there exist another searched terms in the same searched position.
133133
MultiPhraseQuery mq = new MultiPhraseQuery();
134134
mq.Add(new Term[] { new Term("field", "3"), new Term("field", "9") }, 0);

src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public override Query Rewrite(IndexReader reader, MultiTermQuery query)
125125
{
126126
int pos = sort[i];
127127
// docFreq is not used for constant score here, we pass 1
128-
// to explicitely set a fake value, so it's not calculated
128+
// to explicitly set a fake value, so it's not calculated
129129
AddClause(bq, new Term(query.m_field, pendingTerms.Get(pos, new BytesRef())), 1, 1.0f, col.array.termState[pos]);
130130
}
131131
}

src/dotnet/Lucene.Net.Replicator.AspNetCore/AspNetCoreReplicationRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public AspNetCoreReplicationRequest(HttpRequest request)
4343
}
4444

4545
/// <summary>
46-
/// Provides the requested path which mapps to a replication operation.
46+
/// Provides the requested path which maps to a replication operation.
4747
/// </summary>
4848
public string Path => request.PathBase + request.Path;
4949

0 commit comments

Comments
 (0)