Uploaded image for project: 'Lucene.Net'
  1. Lucene.Net
  2. LUCENENET-557

Suspicious code found by PVS-Studio

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • Lucene.Net 3.0.3
    • None
    • Lucene.Net Contrib
    • None

    Description

      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?

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            DieselMachine Ilya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment