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 4bcbe07719d6c77150be8b00cc0e50b95850f297 Author: Shad Storhaug <[email protected]> AuthorDate: Mon Aug 5 08:49:01 2019 +0700 SWEEP: Added StringComparison.Ordinal to all of the string.StartsWith() and string.EndsWith() methods where it was missing --- .../Analysis/Compound/Hyphenation/HyphenationTree.cs | 2 +- src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs | 8 ++++---- src/Lucene.Net.Replicator/IndexReplicationHandler.cs | 4 ++-- src/Lucene.Net.Tests.QueryParser/Xml/TestQueryTemplateManager.cs | 4 ++-- src/Lucene.Net.Tests/Index/TestCompoundFile.cs | 2 +- src/dotnet/tools/lucene-cli/CommandLine/CommandLineApplication.cs | 4 ++-- src/dotnet/tools/lucene-cli/CommandLine/CommandOption.cs | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs b/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs index 5f65b54..1a87cb0 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs @@ -281,7 +281,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation /// <code> /// for (i=0; i<patterns.Length; i++) /// { - /// if (word.Substring(index).StartsWith(patterns[i])) + /// if (word.Substring(index).StartsWith(patterns[i], StringComparison.Ordinal)) /// update_interletter_values(patterns[i]); /// } /// </code> diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs index 8f0567d..e08e8a3 100644 --- a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs +++ b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs @@ -432,14 +432,14 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm if (inMultilineComment) { - if (line.EndsWith(ResourceConstants.EXT_CMT_END)) + if (line.EndsWith(ResourceConstants.EXT_CMT_END, StringComparison.Ordinal)) { inMultilineComment = false; } } else { - if (line.StartsWith(ResourceConstants.EXT_CMT_START)) + if (line.StartsWith(ResourceConstants.EXT_CMT_START, StringComparison.Ordinal)) { inMultilineComment = true; } @@ -558,8 +558,8 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm /// <returns>An RPattern that will match this regex.</returns> private static IRPattern GetPattern(string regex) { - bool startsWith = regex.StartsWith("^"); - bool endsWith = regex.EndsWith("$"); + bool startsWith = regex.StartsWith("^", StringComparison.Ordinal); + bool endsWith = regex.EndsWith("$", StringComparison.Ordinal); string content = regex.Substring(startsWith ? 1 : 0, (endsWith ? regex.Length - 1 : regex.Length) - (startsWith ? 1 : 0)); bool boxes = content.Contains("["); diff --git a/src/Lucene.Net.Replicator/IndexReplicationHandler.cs b/src/Lucene.Net.Replicator/IndexReplicationHandler.cs index 93274a1..d941527 100644 --- a/src/Lucene.Net.Replicator/IndexReplicationHandler.cs +++ b/src/Lucene.Net.Replicator/IndexReplicationHandler.cs @@ -115,7 +115,7 @@ namespace Lucene.Net.Replicator string segmentsFile = files.Last(); //NOTE: Relying on side-effects outside? files.RemoveAt(files.Count - 1); - if (!segmentsFile.StartsWith(IndexFileNames.SEGMENTS) || segmentsFile.Equals(IndexFileNames.SEGMENTS_GEN, StringComparison.Ordinal)) + if (!segmentsFile.StartsWith(IndexFileNames.SEGMENTS, StringComparison.Ordinal) || segmentsFile.Equals(IndexFileNames.SEGMENTS_GEN, StringComparison.Ordinal)) { throw new InvalidOperationException( string.Format("last file to copy+sync must be segments_N but got {0}; check your Revision implementation!", segmentsFile)); @@ -170,7 +170,7 @@ namespace Lucene.Net.Replicator Regex matcher = IndexFileNames.CODEC_FILE_PATTERN; foreach (string file in directory.ListAll() - .Where(file => !commitFiles.Contains(file) && (matcher.IsMatch(file) || file.StartsWith(IndexFileNames.SEGMENTS)))) + .Where(file => !commitFiles.Contains(file) && (matcher.IsMatch(file) || file.StartsWith(IndexFileNames.SEGMENTS, StringComparison.Ordinal)))) { try { diff --git a/src/Lucene.Net.Tests.QueryParser/Xml/TestQueryTemplateManager.cs b/src/Lucene.Net.Tests.QueryParser/Xml/TestQueryTemplateManager.cs index 06b7924..b3dc872 100644 --- a/src/Lucene.Net.Tests.QueryParser/Xml/TestQueryTemplateManager.cs +++ b/src/Lucene.Net.Tests.QueryParser/Xml/TestQueryTemplateManager.cs @@ -74,9 +74,9 @@ namespace Lucene.Net.QueryParsers.Xml public void TestFormTransforms() { //// Sun 1.5 suffers from http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6240963 - //if (Constants.JAVA_VENDOR.StartsWith("Sun") && Constants.JAVA_VERSION.StartsWith("1.5")) { + //if (Constants.JAVA_VENDOR.StartsWith("Sun", StringComparison.Ordinal) && Constants.JAVA_VERSION.StartsWith("1.5", StringComparison.Ordinal)) { // String defLang = Locale.getDefault().getLanguage(); - // assumeFalse("Sun JRE 1.5 suffers from http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6240963 under Turkish locale", defLang.equals("tr") || defLang.equals("az")); + // assumeFalse("Sun JRE 1.5 suffers from http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6240963 under Turkish locale", defLang.equals("tr", StringComparison.Ordinal) || defLang.equals("az", StringComparison.Ordinal)); //} //Cache all the query templates we will be referring to. QueryTemplateManager qtm = new QueryTemplateManager(); diff --git a/src/Lucene.Net.Tests/Index/TestCompoundFile.cs b/src/Lucene.Net.Tests/Index/TestCompoundFile.cs index 5386ab4..7960a79 100644 --- a/src/Lucene.Net.Tests/Index/TestCompoundFile.cs +++ b/src/Lucene.Net.Tests/Index/TestCompoundFile.cs @@ -887,7 +887,7 @@ namespace Lucene.Net.Index { foreach (string file in dir.ListAll()) { - if (file.EndsWith(IndexFileNames.COMPOUND_FILE_EXTENSION)) + if (file.EndsWith(IndexFileNames.COMPOUND_FILE_EXTENSION, StringComparison.Ordinal)) { CompoundFileDirectory cfsDir = new CompoundFileDirectory(dir, file, NewIOContext(Random()), false); CheckFiles(cfsDir); // recurse into cfs diff --git a/src/dotnet/tools/lucene-cli/CommandLine/CommandLineApplication.cs b/src/dotnet/tools/lucene-cli/CommandLine/CommandLineApplication.cs index 7ac7a9c..e3e5a3a 100644 --- a/src/dotnet/tools/lucene-cli/CommandLine/CommandLineApplication.cs +++ b/src/dotnet/tools/lucene-cli/CommandLine/CommandLineApplication.cs @@ -155,11 +155,11 @@ namespace Lucene.Net.Cli.CommandLine string[] longOption = null; string[] shortOption = null; - if (arg.StartsWith("--")) + if (arg.StartsWith("--", StringComparison.Ordinal)) { longOption = arg.Substring(2).Split(new[] { ':', '=' }, 2); } - else if (arg.StartsWith("-")) + else if (arg.StartsWith("-", StringComparison.Ordinal)) { shortOption = arg.Substring(1).Split(new[] { ':', '=' }, 2); } diff --git a/src/dotnet/tools/lucene-cli/CommandLine/CommandOption.cs b/src/dotnet/tools/lucene-cli/CommandLine/CommandOption.cs index 27c5f00..784c9f5 100644 --- a/src/dotnet/tools/lucene-cli/CommandLine/CommandOption.cs +++ b/src/dotnet/tools/lucene-cli/CommandLine/CommandOption.cs @@ -34,11 +34,11 @@ namespace Lucene.Net.Cli.CommandLine foreach (var part in Template.Split(new[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries)) { - if (part.StartsWith("--")) + if (part.StartsWith("--", StringComparison.Ordinal)) { LongName = part.Substring(2); } - else if (part.StartsWith("-")) + else if (part.StartsWith("-", StringComparison.Ordinal)) { var optName = part.Substring(1); @@ -52,7 +52,7 @@ namespace Lucene.Net.Cli.CommandLine ShortName = optName; } } - else if (part.StartsWith("<") && part.EndsWith(">")) + else if (part.StartsWith("<", StringComparison.Ordinal) && part.EndsWith(">", StringComparison.Ordinal)) { ValueName = part.Substring(1, part.Length - 2); }
