hidingmyname opened a new issue, #16933:
URL: https://github.com/apache/lucene/issues/16933
### Description
### Summary
The summary line of `StemmerUtil.startsWith` says "Returns true if the
character array starts with the suffix." The method checks for a prefix. Its
parameter is named `prefix`, and the `@param` and `@return` tags in the same
javadoc both say prefix. The summary line looks like it was copied from
`endsWith` right below it.
### Where
`lucene/analysis/common/src/java/org/apache/lucene/analysis/util/StemmerUtil.java:28-53`:
```java
/**
* Returns true if the character array starts with the suffix.
*
* @param s Input Buffer
* @param len length of input buffer
* @param prefix Prefix string to test
* @return true if <code>s</code> starts with <code>prefix</code>
*/
public static boolean startsWith(char[] s, int len, String prefix) {
final int prefixLen = prefix.length();
if (prefixLen > len) return false;
for (int i = 0; i < prefixLen; i++) if (s[i] != prefix.charAt(i)) return
false;
return true;
}
/**
* Returns true if the character array ends with the suffix.
*
* @param s Input Buffer
* @param len length of input buffer
* @param suffix Suffix string to test
* @return true if <code>s</code> ends with <code>suffix</code>
*/
public static boolean endsWith(char[] s, int len, String suffix) {
```
### Why it matters
To be upfront about scope: `StemmerUtil` is tagged `@lucene.internal`, so
this
is mainly a source-readability fix. Users are not supposed to depend on it.
It's still public and widely used. About 33 other files on `main` reference
it, mostly
language stemmers, and people reading or writing a stemmer go to these
helpers
to check what they do. The summary line is what IDE hovers and the javadoc
method table show, and right now that line says the opposite of the tags
under
it. The fix is one word.
### Suggested fix
```diff
/**
- * Returns true if the character array starts with the suffix.
+ * Returns true if the character array starts with the prefix.
*
* @param s Input Buffer
* @param len length of input buffer
* @param prefix Prefix string to test
```
### Upstream reference
Lucene.NET fixed this in its port in apache/lucenenet@`f934cebea`
("Lucene.Net.Analysis.Util (CharArraySet - WordlistLoader) refactor: member
accessibility and documentation comments"):
```diff
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/StemmerUtil.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/StemmerUtil.cs
@@ -35,12 +34,12 @@ private StemmerUtil()
}
/// <summary>
- /// Returns true if the character array starts with the suffix.
+ /// Returns true if the character array starts with the prefix.
/// </summary>
/// <param name="s"> Input Buffer </param>
/// <param name="len"> length of input buffer </param>
/// <param name="prefix"> Prefix string to test </param>
- /// <returns> true if <code>s</code> starts with
<code>prefix</code> </returns>
+ /// <returns> <c>true</c> if <paramref name="s"/> starts with
<paramref name="prefix"/> </returns>
public static bool StartsWith(char[] s, int len, string prefix)
```
Current Lucene.NET (all `StartsWith` overloads):
```csharp
/// <summary>
/// Returns true if the character array starts with the prefix.
/// </summary>
```
The `<returns>` change in that hunk is C# doc formatting only. The suggested
fix
above is just the word change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]