Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ steps:
- template: publish-test-results.yml
parameters:
testProjectName: 'Lucene.Net.Tests.CodeAnalysis'
framework: 'net8.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
framework: 'net8.0' # Since conditions are not supported for templates, we check for the file existence within publish-test-results.yml
vsTestPlatform: '${{ parameters.vsTestPlatform }}'
osName: '${{ parameters.osName }}'
testResultsFormat: '${{ parameters.testResultsFormat }}'
Expand Down
2,265 changes: 0 additions & 2,265 deletions .build/psake/en-US/psake.psm1-help.xml.old

This file was deleted.

6 changes: 3 additions & 3 deletions .build/psake/public/Assert.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ function Assert {
.EXAMPLE
C:\PS>Assert ( ($i % 2) -eq 0 ) "$i is not an even number"

This exmaple may throw an exception if $i is not an even number
This example may throw an exception if $i is not an even number

Note:
It might be necessary to wrap the condition with paranthesis to force PS to evaluate the condition
It might be necessary to wrap the condition with parenthesis to force PS to evaluate the condition
so that a boolean value is calculated and passed into the 'conditionToCheck' parameter.

Example:
Assert 1 -eq 2 "1 doesn't equal 2"

PS will pass 1 into the condtionToCheck variable and PS will look for a parameter called "eq" and
PS will pass 1 into the conditionToCheck variable and PS will look for a parameter called "eq" and
throw an exception with the following message "A parameter cannot be found that matches parameter name 'eq'"

The solution is to wrap the condition in () so that PS will evaluate it first.
Expand Down
105 changes: 105 additions & 0 deletions .github/linters/Prune-CodespellSuppressions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Reports (and optionally removes) entries in codespell.txt that codespell no longer flags.

.DESCRIPTION
Codespell has no built-in way to detect unused entries in an ignore-words file.
This script runs codespell against the repo with NO ignore-words file, collects the
set of words it flags, and reports any suppression in codespell.txt that is not in
that set (i.e., the suppression is no longer needed).

The pre-commit hook invocation in .pre-commit-config.yaml is mirrored here so the
scan covers the same files codespell would normally see.

.PARAMETER Apply
Rewrite codespell.txt with the unused entries removed. Without this switch the
script only reports.

.PARAMETER CodespellCommand
Override the codespell executable (default: "codespell").
#>
[CmdletBinding()]
param(
[switch]$Apply,
[string]$CodespellCommand = 'codespell'
)

$ErrorActionPreference = 'Stop'

$repoRoot = (& git -C $PSScriptRoot rev-parse --show-toplevel).Trim()
$suppressionsFile = Join-Path $repoRoot '.github/linters/codespell.txt'

if (-not (Test-Path $suppressionsFile)) {
throw "Suppressions file not found: $suppressionsFile"
}

# Must match the `exclude:` regex for the codespell hook in .pre-commit-config.yaml.
$excludeRegex = '^src/Lucene\.Net\.Analysis\.Common/Analysis/../.*\.rslp$|^.*Lucene\.Net\.Tests.*$'

$suppressions = Get-Content -LiteralPath $suppressionsFile |
Where-Object { $_ -ne '' }

Write-Host "Loaded $($suppressions.Count) suppression(s) from $suppressionsFile"
Write-Host "Enumerating git-tracked files (to match pre-commit's view of the repo)..."

# pre-commit only feeds tracked files to codespell; running codespell directly would
# also walk bin/, obj/, and other gitignored output. Drive it with `git ls-files`
# so the two scans cover the same file set.
Push-Location $repoRoot
try {
$trackedFiles = & git ls-files
Write-Host "Running codespell on $($trackedFiles.Count) tracked file(s) with NO ignore list..."

# Write the file list to a temp argsfile and pass it with codespell's "@PATH"
# syntax. This avoids OS argv length limits on large file lists.
$argsFile = New-TemporaryFile
try {
Set-Content -LiteralPath $argsFile -Value $trackedFiles -Encoding utf8
# We don't care about exit code: a non-zero exit just means it found
# misspellings, which is exactly what we want.
$rawOutput = & $CodespellCommand "@$argsFile" 2>&1
}
finally {
Remove-Item -LiteralPath $argsFile -ErrorAction SilentlyContinue
}
}
finally {
Pop-Location
}

# Codespell output format: "<path>:<line>: <flagged> ==> <suggestion>"
# Filter out paths that match the pre-commit exclude regex, then extract the flagged word.
$flagged = New-Object System.Collections.Generic.HashSet[string]
foreach ($line in $rawOutput) {
if ($line -notmatch '^(?<path>[^:]+):\d+:\s+(?<word>\S+)\s+==>') { continue }
$path = $Matches['path']
if ($path -match $excludeRegex) { continue }
# Suppressions are case-sensitive and matched against the dictionary entry's case.
[void]$flagged.Add($Matches['word'].ToLowerInvariant())
}

Write-Host "Codespell flagged $($flagged.Count) distinct word(s) (after applying exclude regex)."

$unused = $suppressions | Where-Object { -not $flagged.Contains($_.ToLowerInvariant()) }

if (-not $unused) {
Write-Host "No unused suppressions found. codespell.txt is clean." -ForegroundColor Green
return
}

Write-Host ""
Write-Host "Unused suppressions ($($unused.Count)):" -ForegroundColor Yellow
$unused | ForEach-Object { Write-Host " $_" }

if ($Apply) {
$keep = $suppressions | Where-Object { $flagged.Contains($_.ToLowerInvariant()) }
# Preserve trailing newline that codespell.txt currently has.
Set-Content -LiteralPath $suppressionsFile -Value $keep -Encoding utf8
Write-Host ""
Write-Host "Removed $($unused.Count) unused entr$(if ($unused.Count -eq 1) { 'y' } else { 'ies' }) from codespell.txt." -ForegroundColor Green
} else {
Write-Host ""
Write-Host "Re-run with -Apply to remove these from codespell.txt."
exit 1
}
7 changes: 0 additions & 7 deletions .github/linters/codespell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ compatibity
compatiblity
completly
concret
condtions
Comment thread
paulirwin marked this conversation as resolved.
confguration
conjuction
conjuntions
Expand Down Expand Up @@ -127,9 +126,6 @@ entend
equest
euclidian
everytime
execeptions
exmaple
explicitely
explicity
faild
failue
Expand Down Expand Up @@ -207,7 +203,6 @@ kake
ket
lama
lief
lien
loner
longwinded
maching
Expand Down Expand Up @@ -285,8 +280,6 @@ plaforms
pluse
pont
posin
postion
postions
pre-pended
pres
prevend
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Highlighter/Highlight/WeightedSpanTerm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public WeightedSpanTerm(float weight, string term, bool positionSensitive)
/// <summary>
/// Checks to see if this term is valid at <paramref name="position"/>.
/// </summary>
/// <param name="position">to check against valid term postions</param>
/// <param name="position">to check against valid term positions</param>
/// <returns>true iff this term is a hit at this position</returns>
public virtual bool CheckPosition(int position)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ namespace Lucene.Net.Replicator.Http.Abstractions
public interface IReplicationRequest
{
/// <summary>
/// Provides the requested path which mapps to a replication operation.
/// Provides the requested path which maps to a replication operation.
/// </summary>
string Path { get; }

/// <summary>
/// Returns the requested query parameter or null if not present.
/// </summary>
/// <remarks>
/// May though execeptions if the same parameter is provided multiple times, consult the documentation for the specific implementation.
/// May throw exceptions if the same parameter is provided multiple times, consult the documentation for the specific implementation.
/// </remarks>
/// <param name="name">the name of the requested parameter</param>
/// <returns>the value of the requested parameter or null if not present</returns>
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Tests/Search/TestPositionIncrement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public virtual void TestSetPosition()
hits = searcher.Search(q, null, 1000).ScoreDocs;
Assert.AreEqual(0, hits.Length);

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

// multi-phrase query should succed for non existing searched term
// multi-phrase query should succeed for non existing searched term
// because there exist another searched terms in the same searched position.
MultiPhraseQuery mq = new MultiPhraseQuery();
mq.Add(new Term[] { new Term("field", "3"), new Term("field", "9") }, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public override Query Rewrite(IndexReader reader, MultiTermQuery query)
{
int pos = sort[i];
// docFreq is not used for constant score here, we pass 1
// to explicitely set a fake value, so it's not calculated
// to explicitly set a fake value, so it's not calculated
AddClause(bq, new Term(query.m_field, pendingTerms.Get(pos, new BytesRef())), 1, 1.0f, col.array.termState[pos]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public AspNetCoreReplicationRequest(HttpRequest request)
}

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

Expand Down
Loading