You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2022/10/25 06:58:21 UTC

[GitHub] [lucenenet] nikcio opened a new issue, #719: Possible ICUTransformFilter bug

nikcio opened a new issue, #719:
URL: https://github.com/apache/lucenenet/issues/719

   The following code has triggered an SonarCloud issue:
   https://github.com/apache/lucenenet/blob/b6cf28b78c85f33e66d89abe399c4523dd41dc80/src/Lucene.Net.Analysis.ICU/Analysis/Icu/ICUTransformFilter.cs#L135-L140
   
   The `Replace` statement has a 2nd paramenter that always defaults to 0. It seems to be a bug.
   
   Original code: 
   https://github.com/apache/lucene/blob/8fdf89690404c0e65784b2c5477552b9dec58591/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilter.java#L138-L142
   
   Traced the issue back to: https://github.com/apache/lucenenet/commit/bebbae94145916520972ce25b3ebc2778db7c699#diff-ff3f44867a5688ccfea635f8d3c39fca938e698e60df8b6016a329a0e32fb40c
   
   Before this commit it seems that it was `Replace(dest, dest....` instead of `Replace(dest, dest - dest...`. So it might be a mistake 
   
   Sonar issue: https://sonarcloud.io/project/issues?issues=AYPAuQyghbfJOGLOocHG&open=AYPAuQyghbfJOGLOocHG&id=nikcio_lucenenet


-- 
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: dev-unsubscribe@lucenenet.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [lucenenet] nikcio closed issue #719: Possible ICUTransformFilter bug

Posted by GitBox <gi...@apache.org>.
nikcio closed issue #719: Possible ICUTransformFilter bug
URL: https://github.com/apache/lucenenet/issues/719


-- 
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: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [lucenenet] NightOwl888 commented on issue #719: Possible ICUTransformFilter bug

Posted by GitBox <gi...@apache.org>.
NightOwl888 commented on issue #719:
URL: https://github.com/apache/lucenenet/issues/719#issuecomment-1290729659

   Nope. The commit https://github.com/apache/lucenenet/commit/bebbae94145916520972ce25b3ebc2778db7c699#diff-ff3f44867a5688ccfea635f8d3c39fca938e698e60df8b6016a329a0e32fb40c is converting from `limit` (exclusive end index) to `length` to match .NET APIs. However, the overload of `Replace()` that is being called had the first 2 parameters `start` and `limit` which were both set to the variable `dest` (now renamed to `destinationIndex`). To convert using the formula:
   
   ```length = limit - start```
   
   We end up with:
   
   ```length = dest - dest```
   
   Renamed:
   
   ```length = destinationIndex - destinationIndex```
   
   This basically makes the `Replace()` method into an effective `Insert()` operation at `destinationIndex` for `text.Length` characters. At the end of the day, having the same value for both `start` and `limit` (or `end`) in Java means use a zero-length slice of the array.
   
   Although the `length` of the "value to replace" is always `0`, I find it is helpful to show your work in the conversion rather than simply setting it to `0`. There are several other places where we are subtracting `0` from `limit` (or `end`) just to show that it was converted, even though this obviously has no real effect on the application.
   


-- 
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: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [lucenenet] nikcio commented on issue #719: Possible ICUTransformFilter bug

Posted by GitBox <gi...@apache.org>.
nikcio commented on issue #719:
URL: https://github.com/apache/lucenenet/issues/719#issuecomment-1291024321

   Super I'll mark the issue resolved in sonar👍


-- 
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: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org