You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2022/10/25 00:19:06 UTC
[lucenenet] branch master updated: sweep: Review for CA1822: Mark members as static
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new b6cf28b78 sweep: Review for CA1822: Mark members as static
b6cf28b78 is described below
commit b6cf28b78c85f33e66d89abe399c4523dd41dc80
Author: Nikolaj Brask-Nielsen <ni...@gmail.com>
AuthorDate: Mon Oct 24 08:12:40 2022 +0200
sweep: Review for CA1822: Mark members as static
---
src/Lucene.Net.Analysis.Common/Analysis/Br/BrazilianStemmer.cs | 6 +++---
src/Lucene.Net.Analysis.Common/Analysis/De/GermanLightStemmer.cs | 4 ++--
src/Lucene.Net.Analysis.Common/Analysis/Fi/FinnishLightStemmer.cs | 2 +-
.../Analysis/Hu/HungarianLightStemmer.cs | 4 ++--
src/Lucene.Net.Analysis.Common/Analysis/In/IndicNormalizer.cs | 2 +-
.../Analysis/Util/AbstractAnalysisFactory.cs | 7 +++++++
src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs | 1 +
src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs | 2 +-
.../Support/JavaCompatibility/LuceneTestCase.cs | 2 ++
.../Support/Util/LuceneRandomSeedInitializer.cs | 2 ++
.../Support/Util/LuceneSetUpFixtureBuilder.cs | 2 ++
src/Lucene.Net/Index/DocumentsWriterFlushQueue.cs | 2 ++
12 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Br/BrazilianStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Br/BrazilianStemmer.cs
index a7046d1a5..0e9572b28 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Br/BrazilianStemmer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Br/BrazilianStemmer.cs
@@ -131,7 +131,7 @@ namespace Lucene.Net.Analysis.Br
/// no such non-vowel.
/// </summary>
/// <returns> null or a string representing R1 </returns>
- private string GetR1(string value)
+ private static string GetR1(string value) // LUCENENET: CA1822: Mark members as static
{
int i;
int j;
@@ -190,7 +190,7 @@ namespace Lucene.Net.Analysis.Br
/// found.
/// </summary>
/// <returns> null or a string representing RV </returns>
- private string GetRV(string value)
+ private static string GetRV(string value) // LUCENENET: CA1822: Mark members as static
{
int i;
int j;
@@ -366,7 +366,7 @@ namespace Lucene.Net.Analysis.Br
/// Remove a <see cref="string"/> suffix
/// </summary>
/// <returns> the <see cref="string"/> without the suffix </returns>
- private string RemoveSuffix(string value, string toRemove)
+ private static string RemoveSuffix(string value, string toRemove) // LUCENENET: CA1822: Mark members as static
{
// be-safe !!!
if ((value is null) || (toRemove is null) || !Suffix(value, toRemove))
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/De/GermanLightStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/De/GermanLightStemmer.cs
index 0b93327c2..f11f485a1 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/De/GermanLightStemmer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/De/GermanLightStemmer.cs
@@ -120,7 +120,7 @@ namespace Lucene.Net.Analysis.De
}
}
- private int Step1(char[] s, int len)
+ private static int Step1(char[] s, int len) // LUCENENET: CA1822: Mark members as static
{
if (len > 5 && s[len - 3] == 'e' && s[len - 2] == 'r' && s[len - 1] == 'n')
{
@@ -152,7 +152,7 @@ namespace Lucene.Net.Analysis.De
return len;
}
- private int Step2(char[] s, int len)
+ private static int Step2(char[] s, int len) // LUCENENET: CA1822: Mark members as static
{
if (len > 5 && s[len - 3] == 'e' && s[len - 2] == 's' && s[len - 1] == 't')
{
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Fi/FinnishLightStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Fi/FinnishLightStemmer.cs
index 31ddc82ec..b98aee035 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Fi/FinnishLightStemmer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Fi/FinnishLightStemmer.cs
@@ -145,7 +145,7 @@ namespace Lucene.Net.Analysis.Fi
return len;
}
- private int Step3(char[] s, int len)
+ private static int Step3(char[] s, int len) // LUCENENET: CA1822: Mark members as static
{
if (len > 8)
{
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Hu/HungarianLightStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Hu/HungarianLightStemmer.cs
index 92d83c428..f70764b77 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Hu/HungarianLightStemmer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Hu/HungarianLightStemmer.cs
@@ -103,7 +103,7 @@ namespace Lucene.Net.Analysis.Hu
return Normalize(s, len);
}
- private int RemoveCase(char[] s, int len)
+ private static int RemoveCase(char[] s, int len) // LUCENENET: CA1822: Mark members as static
{
if (len > 6 && StemmerUtil.EndsWith(s, len, "kent"))
{
@@ -156,7 +156,7 @@ namespace Lucene.Net.Analysis.Hu
return len;
}
- private int RemovePossessive(char[] s, int len)
+ private static int RemovePossessive(char[] s, int len) // LUCENENET: CA1822: Mark members as static
{
if (len > 6)
{
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/In/IndicNormalizer.cs b/src/Lucene.Net.Analysis.Common/Analysis/In/IndicNormalizer.cs
index 4ecffca06..0bddf84e2 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/In/IndicNormalizer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/In/IndicNormalizer.cs
@@ -287,7 +287,7 @@ namespace Lucene.Net.Analysis.In
/// <summary>
/// Compose into standard form any compositions in the decompositions table.
/// </summary>
- private int Compose(int ch0, Regex block0, ScriptData sd, char[] text, int pos, int len)
+ private static int Compose(int ch0, Regex block0, ScriptData sd, char[] text, int pos, int len) // LUCENENET: CA1822: Mark members as static
{
if (pos + 1 >= len) // need at least 2 chars!
{
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
index 241f7a81f..0f2b41ba9 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
@@ -5,6 +5,7 @@ using Lucene.Net.Support;
using Lucene.Net.Util;
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Text;
@@ -80,6 +81,7 @@ namespace Lucene.Net.Analysis.Util
/// or <see cref="TokenFilterFactory.Create(TokenStream)"/> methods,
/// to inform user, that for this factory a <see cref="m_luceneMatchVersion"/> is required
/// </summary>
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
protected void AssureMatchVersion() // LUCENENET TODO: Remove this method (not used anyway in .NET)
{
// LUCENENET NOTE: since luceneMatchVersion can never be null in .NET,
@@ -185,6 +187,7 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// NOTE: This was getInt() in Lucene
/// </summary>
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
protected int GetInt32(IDictionary<string, string> args, string name, int defaultVal)
{
if (args.TryGetValue(name, out string s))
@@ -200,6 +203,7 @@ namespace Lucene.Net.Analysis.Util
return bool.Parse(Require(args, name));
}
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
protected bool GetBoolean(IDictionary<string, string> args, string name, bool defaultVal)
{
if (args.TryGetValue(name, out string s))
@@ -221,6 +225,7 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// NOTE: This was getFloat() in Lucene
/// </summary>
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
protected float GetSingle(IDictionary<string, string> args, string name, float defaultVal)
{
if (args.TryGetValue(name, out string s))
@@ -351,6 +356,7 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// Returns the resource's lines (with content treated as UTF-8)
/// </summary>
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
protected IList<string> GetLines(IResourceLoader loader, string resource)
{
return WordlistLoader.GetLines(loader.OpenResource(resource), Encoding.UTF8);
@@ -388,6 +394,7 @@ namespace Lucene.Net.Analysis.Util
/// </summary>
/// <param name="fileNames"> the string containing file names </param>
/// <returns> a list of file names with the escaping backslashed removed </returns>
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
protected IList<string> SplitFileNames(string fileNames)
{
if (fileNames is null)
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
index 52bd5eb8e..8458ca33e 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
@@ -261,6 +261,7 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// Converts a sequence of unicode code points to a sequence of .NET characters. </summary>
/// <returns> the number of chars written to the destination buffer </returns>
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
public int ToChars(int[] src, int srcOff, int srcLen, char[] dest, int destOff)
{
if (srcLen < 0)
diff --git a/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs b/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs
index 66442c904..c3f4d9dba 100644
--- a/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs
+++ b/src/Lucene.Net.Misc/Index/Sorter/BlockJoinComparatorSource.cs
@@ -243,7 +243,7 @@ namespace Lucene.Net.Index.Sorter
}
}
- internal int Compare(int docID1, int docID2, FieldComparer[] comparers, int[] reverseMul)
+ internal static int Compare(int docID1, int docID2, FieldComparer[] comparers, int[] reverseMul) // LUCENENET: CA1822: Mark members as static
{
for (int i = 0; i < comparers.Length; i++)
{
diff --git a/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs
index e20635daa..a13fae1bd 100644
--- a/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Assert = Lucene.Net.TestFramework.Assert;
using JCG = J2N.Collections.Generic;
@@ -376,6 +377,7 @@ namespace Lucene.Net.Util
}
}
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[DebuggerStepThrough]
internal double randomGaussian()
diff --git a/src/Lucene.Net.TestFramework/Support/Util/LuceneRandomSeedInitializer.cs b/src/Lucene.Net.TestFramework/Support/Util/LuceneRandomSeedInitializer.cs
index 0e8ff50b6..5d95ef7a7 100644
--- a/src/Lucene.Net.TestFramework/Support/Util/LuceneRandomSeedInitializer.cs
+++ b/src/Lucene.Net.TestFramework/Support/Util/LuceneRandomSeedInitializer.cs
@@ -1,6 +1,7 @@
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
@@ -140,6 +141,7 @@ namespace Lucene.Net.Util
/// <param name="fixture">The test fixture.</param>
/// <param name="randomizedContext">The randomized context to associate with the fixture.</param>
/// <returns>The randomized context.</returns>
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
public RandomizedContext InitializeTestFixture(Test fixture, RandomizedContext randomizedContext)
{
if (fixture is null)
diff --git a/src/Lucene.Net.TestFramework/Support/Util/LuceneSetUpFixtureBuilder.cs b/src/Lucene.Net.TestFramework/Support/Util/LuceneSetUpFixtureBuilder.cs
index 81eccfa19..65ae19f4c 100644
--- a/src/Lucene.Net.TestFramework/Support/Util/LuceneSetUpFixtureBuilder.cs
+++ b/src/Lucene.Net.TestFramework/Support/Util/LuceneSetUpFixtureBuilder.cs
@@ -2,6 +2,7 @@
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Threading;
@@ -31,6 +32,7 @@ namespace Lucene.Net.Util
/// </summary>
internal class LuceneSetUpFixtureBuilder
{
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
public TestSuite BuildFrom(ITypeInfo typeInfo)
{
var setUpFixtureType = new DefaultNamespaceTypeWrapper(typeof(LuceneTestCase.SetUpFixture));
diff --git a/src/Lucene.Net/Index/DocumentsWriterFlushQueue.cs b/src/Lucene.Net/Index/DocumentsWriterFlushQueue.cs
index 1a15b67fc..f8f2ac8ef 100644
--- a/src/Lucene.Net/Index/DocumentsWriterFlushQueue.cs
+++ b/src/Lucene.Net/Index/DocumentsWriterFlushQueue.cs
@@ -2,6 +2,7 @@
using Lucene.Net.Diagnostics;
using Lucene.Net.Support.Threading;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Threading;
namespace Lucene.Net.Index
@@ -299,6 +300,7 @@ namespace Lucene.Net.Index
indexWriter.PublishFlushedSegment(newSegment.segmentInfo, segmentUpdates, globalPacket);
}
+ [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "By design")]
protected void FinishFlush(IndexWriter indexWriter, FlushedSegment newSegment, FrozenBufferedUpdates bufferedUpdates)
{
// Finish the flushed segment and publish it to IndexWriter