You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Shad Storhaug (JIRA)" <ji...@apache.org> on 2017/06/28 23:13:00 UTC

[jira] [Closed] (LUCENENET-557) Suspicious code found by PVS-Studio

     [ https://issues.apache.org/jira/browse/LUCENENET-557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shad Storhaug closed LUCENENET-557.
-----------------------------------
    Resolution: Won't Fix

Being that this code is ported from Java, there are certain to be some things that don't pass in certain .NET code analyzers. Some of this code (such as that of QueryParser) was originally generated from JFlex, and is therefore not very user maintainable.

Suffice to say if there is no errant behavior caused by these "issues", we don't consider them to be bugs. But if they bother you too much you can always submit a pull request with the fix. But do make sure the "fix" actually passes all of the tests. That said, 3.0.3 is no longer being maintained so we won't be accepting any pull requests for it.

> Suspicious code found by PVS-Studio
> -----------------------------------
>
>                 Key: LUCENENET-557
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-557
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Contrib
>    Affects Versions: Lucene.Net 3.0.3
>            Reporter: Ilya
>
> I have found several issues by analyzing Lucene.Net with PVS-Studio static analyzer.
> 1. V3035 Consider inspecting the 'substCount =+ 2' expression. Probably '+=' should be used here. Contrib.Analyzers GermanStemmer.cs 224
> 2. V3020 An unconditional 'return' within a loop. Contrib.Analyzers NGramTokenFilter.cs 109
> Possible if statement should be used here instead of while
> while (curPos + curGramSize <= curTermLength)
> {     // while there is input
>     ClearAttributes();
>     termAtt.SetTermBuffer(curTermBuffer, curPos, curGramSize);
>     offsetAtt.SetOffset(tokStart + curPos, tokStart + curPos + curGramSize);
>     curPos++;
>     return true;
> }
> 3. V3021 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless Contrib.Analyzers BrazilianStemmer.cs 1153
> if (suffix(RV, "iu"))
> {
>     CT = removeSuffix(CT, "iu"); return true;
> }
> if (suffix(RV, "iu"))
> {
>     CT = removeSuffix(CT, "iu"); return true;
> }
> 4. V3022 Expression 'side == null' is always false. Contrib.Analyzers EdgeNGramTokenizer.cs 147
> Because side is a enum
> 5. V3029 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 517, 523. Lucene.Net QueryParserTokenManager.cs 517
> Maybe JjCanMove_1 should be used here?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)