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/11/05 18:54:49 UTC
[lucenenet] 02/04: SWEEP: Changed all public constructors of abstract classes to protected, except where it would be a problem for Reflection calls. (fixes #677)
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
commit 568e4e45c1cf967b21fb36bdd39a10644aa70725
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sat Nov 5 23:38:40 2022 +0700
SWEEP: Changed all public constructors of abstract classes to protected, except where it would be a problem for Reflection calls. (fixes #677)
---
.../Analysis/CharFilter/BaseCharFilter.cs | 4 ++--
src/Lucene.Net.Analysis.Common/Analysis/Synonym/SynonymMap.cs | 2 +-
src/Lucene.Net.Analysis.Common/Analysis/Util/CharTokenizer.cs | 6 +++---
src/Lucene.Net.Analysis.Phonetic/Language/ColognePhonetic.cs | 4 ++--
src/Lucene.Net.Expressions/Bindings.cs | 5 ++++-
src/Lucene.Net.Expressions/Expression.cs | 4 +++-
src/Lucene.Net.Queries/TermsFilter.cs | 4 ++--
src/Lucene.Net.QueryParser/Surround/Query/RewriteQuery.cs | 4 ++--
src/Lucene.Net/Support/Util/NumberFormat.cs | 2 +-
9 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/CharFilter/BaseCharFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/CharFilter/BaseCharFilter.cs
index 5fd9bc9d0..111003aed 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/CharFilter/BaseCharFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/CharFilter/BaseCharFilter.cs
@@ -1,4 +1,4 @@
-// Lucene version compatibility level 4.8.1
+// Lucene version compatibility level 4.8.1
using J2N.Numerics;
using Lucene.Net.Diagnostics;
using Lucene.Net.Support;
@@ -38,7 +38,7 @@ namespace Lucene.Net.Analysis.CharFilters
private int[] diffs;
private int size = 0;
- public BaseCharFilter(TextReader @in)
+ protected BaseCharFilter(TextReader @in) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
: base(@in)
{
}
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SynonymMap.cs b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SynonymMap.cs
index ec46b712b..15c2642d4 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SynonymMap.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SynonymMap.cs
@@ -338,7 +338,7 @@ namespace Lucene.Net.Analysis.Synonym
{
private readonly Analyzer analyzer;
- public Parser(bool dedup, Analyzer analyzer)
+ protected Parser(bool dedup, Analyzer analyzer) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
: base(dedup)
{
this.analyzer = analyzer;
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharTokenizer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharTokenizer.cs
index c1797fa29..74674f63f 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharTokenizer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharTokenizer.cs
@@ -1,4 +1,4 @@
-// Lucene version compatibility level 4.8.1
+// Lucene version compatibility level 4.8.1
using J2N;
using Lucene.Net.Analysis.TokenAttributes;
using Lucene.Net.Diagnostics;
@@ -71,7 +71,7 @@ namespace Lucene.Net.Analysis.Util
/// Lucene version to match </param>
/// <param name="input">
/// the input to split up into tokens </param>
- public CharTokenizer(LuceneVersion matchVersion, TextReader input)
+ protected CharTokenizer(LuceneVersion matchVersion, TextReader input) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
: base(input)
{
Init(matchVersion);
@@ -86,7 +86,7 @@ namespace Lucene.Net.Analysis.Util
/// the attribute factory to use for this <see cref="Tokenizer"/> </param>
/// <param name="input">
/// the input to split up into tokens </param>
- public CharTokenizer(LuceneVersion matchVersion, AttributeFactory factory, TextReader input)
+ protected CharTokenizer(LuceneVersion matchVersion, AttributeFactory factory, TextReader input) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
: base(factory, input)
{
Init(matchVersion);
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/ColognePhonetic.cs b/src/Lucene.Net.Analysis.Phonetic/Language/ColognePhonetic.cs
index 29540edcc..a84104e97 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/ColognePhonetic.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/ColognePhonetic.cs
@@ -193,13 +193,13 @@ namespace Lucene.Net.Analysis.Phonetic.Language
protected int m_length = 0;
- public CologneBuffer(char[] data)
+ protected CologneBuffer(char[] data) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
{
this.m_data = data;
this.m_length = data.Length;
}
- public CologneBuffer(int buffSize)
+ protected CologneBuffer(int buffSize) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
{
this.m_data = new char[buffSize];
this.m_length = 0;
diff --git a/src/Lucene.Net.Expressions/Bindings.cs b/src/Lucene.Net.Expressions/Bindings.cs
index 303a2c370..923455741 100644
--- a/src/Lucene.Net.Expressions/Bindings.cs
+++ b/src/Lucene.Net.Expressions/Bindings.cs
@@ -1,4 +1,5 @@
-using Lucene.Net.Queries.Function;
+using Lucene.Net.Queries.Function;
+using System.Diagnostics.CodeAnalysis;
namespace Lucene.Net.Expressions
{
@@ -35,6 +36,8 @@ namespace Lucene.Net.Expressions
/// Sole constructor. (For invocation by subclass
/// constructors, typically implicit.)
/// </remarks>
+ [SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "This is a SonarCloud issue")]
+ [SuppressMessage("CodeQuality", "S3442:\"abstract\" classes should not have \"public\" constructors", Justification = "Public is required for Relection")]
public Bindings() // LUCENENET NOTE: This must be public for the Reflection code to work right.
{
}
diff --git a/src/Lucene.Net.Expressions/Expression.cs b/src/Lucene.Net.Expressions/Expression.cs
index dfa292b6b..94cf0fda6 100644
--- a/src/Lucene.Net.Expressions/Expression.cs
+++ b/src/Lucene.Net.Expressions/Expression.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Queries.Function;
+using Lucene.Net.Queries.Function;
using Lucene.Net.Search;
using Lucene.Net.Support;
using System.Diagnostics.CodeAnalysis;
@@ -63,6 +63,8 @@ namespace Lucene.Net.Expressions
/// <param name="variables">
/// Names of external variables referred to by the expression
/// </param>
+ [SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "This is a SonarCloud issue")]
+ [SuppressMessage("CodeQuality", "S3442:\"abstract\" classes should not have \"public\" constructors", Justification = "Public is required for Relection")]
public Expression(string sourceText, string[] variables) // LUCENENET NOTE: This must be public for the Reflection code to work right.
{
// javadocs
diff --git a/src/Lucene.Net.Queries/TermsFilter.cs b/src/Lucene.Net.Queries/TermsFilter.cs
index 555ef7000..23e138c60 100644
--- a/src/Lucene.Net.Queries/TermsFilter.cs
+++ b/src/Lucene.Net.Queries/TermsFilter.cs
@@ -398,11 +398,11 @@ namespace Lucene.Net.Queries
public abstract bool MoveNext();
- public FieldAndTermEnum()
+ protected FieldAndTermEnum() // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
{
}
- public FieldAndTermEnum(string field)
+ protected FieldAndTermEnum(string field) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
{
this.Field = field;
}
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/RewriteQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/RewriteQuery.cs
index e633c7849..21ffc858f 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/RewriteQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/RewriteQuery.cs
@@ -26,10 +26,10 @@ namespace Lucene.Net.QueryParsers.Surround.Query
protected readonly string m_fieldName;
protected readonly BasicQueryFactory m_qf;
- public RewriteQuery(
+ protected RewriteQuery(
SQ srndQuery,
string fieldName,
- BasicQueryFactory qf)
+ BasicQueryFactory qf) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
{
this.m_srndQuery = srndQuery;
this.m_fieldName = fieldName;
diff --git a/src/Lucene.Net/Support/Util/NumberFormat.cs b/src/Lucene.Net/Support/Util/NumberFormat.cs
index 780ccc2c7..a460530b7 100644
--- a/src/Lucene.Net/Support/Util/NumberFormat.cs
+++ b/src/Lucene.Net/Support/Util/NumberFormat.cs
@@ -40,7 +40,7 @@ namespace Lucene.Net.Util
//private int maximumFractionDigits;
//private int minimumFractionDigits;
- public NumberFormat(IFormatProvider formatProvider)
+ protected NumberFormat(IFormatProvider formatProvider) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
{
this.formatProvider = formatProvider;
}