1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Resolve CA2249 inspections

"Use `string.Contains` instead of `string.IndexOf` to improve
readability"
This commit is contained in:
Bartłomiej Dach 2020-11-01 18:54:44 +01:00
parent 89bf7b1bd6
commit 3090b6ccb5
4 changed files with 4 additions and 4 deletions

View File

@ -347,7 +347,7 @@ namespace osu.Game.Beatmaps.Formats
/// <param name="line">The line which may contains variables.</param>
private void decodeVariables(ref string line)
{
while (line.IndexOf('$') >= 0)
while (line.Contains('$'))
{
string origLine = line;

View File

@ -84,7 +84,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
matchingFilter &= r.Room.Playlist.Count == 0 || r.Room.Playlist.Any(i => i.Ruleset.Value.Equals(criteria.Ruleset));
if (!string.IsNullOrEmpty(criteria.SearchString))
matchingFilter &= r.FilterTerms.Any(term => term.IndexOf(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase) >= 0);
matchingFilter &= r.FilterTerms.Any(term => term.Contains(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase));
r.MatchingFilter = matchingFilter;
}

View File

@ -59,7 +59,7 @@ namespace osu.Game.Screens.Select.Carousel
var terms = Beatmap.SearchableTerms;
foreach (var criteriaTerm in criteria.SearchTerms)
match &= terms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0);
match &= terms.Any(term => term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase));
// if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs.
// this should be done after text matching so we can prioritise matching numbers in metadata.

View File

@ -126,7 +126,7 @@ namespace osu.Game.Screens.Select
if (string.IsNullOrEmpty(value))
return false;
return value.IndexOf(SearchTerm, StringComparison.InvariantCultureIgnoreCase) >= 0;
return value.Contains(SearchTerm, StringComparison.InvariantCultureIgnoreCase);
}
public string SearchTerm;