Skip to content

Commit 6cde32d

Browse files
Update message of S4635 (#7435)
1 parent b6ce681 commit 6cde32d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

analyzers/its/sources/ManuallyAddedNoncompliantIssues.CS/IntentionalFindings/S4635.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ namespace IntentionalFindings
1313
public static class S4635
1414
{
1515
public static int TestMethod() =>
16-
"Test".Substring(1).IndexOf('t', StringComparison.InvariantCulture); // Noncompliant (S4635) {{Replace 'IndexOf' with the overload that accepts an offset parameter.}}
16+
"Test".Substring(1).IndexOf('t', StringComparison.InvariantCulture); // Noncompliant (S4635) {{Replace 'IndexOf' with the overload that accepts a startIndex parameter.}}
1717
}
1818
}

analyzers/src/SonarAnalyzer.CSharp/Rules/StringOffsetMethods.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace SonarAnalyzer.Rules.CSharp
2424
public sealed class StringOffsetMethods : SonarDiagnosticAnalyzer
2525
{
2626
internal const string DiagnosticId = "S4635";
27-
private const string MessageFormat = "Replace '{0}' with the overload that accepts an offset parameter.";
27+
private const string MessageFormat = "Replace '{0}' with the overload that accepts a startIndex parameter.";
2828

2929
private static readonly DiagnosticDescriptor rule =
3030
DescriptorFactory.Create(DiagnosticId, MessageFormat);

analyzers/tests/SonarAnalyzer.UnitTest/TestCases/StringOffsetMethods.CSharp11.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class StringOffsetMethods
66
{
77
public StringOffsetMethods()
88
{
9-
"""Test""".Substring(1).IndexOf('t'); // Noncompliant {{Replace 'IndexOf' with the overload that accepts an offset parameter.}}
9+
"""Test""".Substring(1).IndexOf('t'); // Noncompliant {{Replace 'IndexOf' with the overload that accepts a startIndex parameter.}}
1010
}
1111
}
1212
}

analyzers/tests/SonarAnalyzer.UnitTest/TestCases/StringOffsetMethods.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class StringOffsetMethods
66
{
77
public StringOffsetMethods()
88
{
9-
"Test".Substring(1).IndexOf('t'); // Noncompliant {{Replace 'IndexOf' with the overload that accepts an offset parameter.}}
9+
"Test".Substring(1).IndexOf('t'); // Noncompliant {{Replace 'IndexOf' with the overload that accepts a startIndex parameter.}}
1010
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1111
}
1212

@@ -34,23 +34,23 @@ public void StringOffsetMethodsCases(string x)
3434
"Test".IndexOfAny(new[] { 't' });
3535
"Test".IndexOfAny(new[] { 't' }, 2);
3636
"Test".IndexOfAny(new[] { 't' }, 1, 2);
37-
"Test".Substring(1).IndexOfAny(new[] { 't' }); // Noncompliant {{Replace 'IndexOfAny' with the overload that accepts an offset parameter.}}
37+
"Test".Substring(1).IndexOfAny(new[] { 't' }); // Noncompliant {{Replace 'IndexOfAny' with the overload that accepts a startIndex parameter.}}
3838
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939

4040
"Test".LastIndexOf('t');
4141
"Test".LastIndexOf('t', 1);
4242
"Test".LastIndexOf("t");
4343
"Test".LastIndexOf("t", 1);
4444
"Test".LastIndexOf("t", 1, 3);
45-
"Test".Substring(1).LastIndexOf('t'); // Noncompliant {{Replace 'LastIndexOf' with the overload that accepts an offset parameter.}}
45+
"Test".Substring(1).LastIndexOf('t'); // Noncompliant {{Replace 'LastIndexOf' with the overload that accepts a startIndex parameter.}}
4646
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747
"Test".Substring(1).LastIndexOf("t"); // Noncompliant
4848

4949

5050
"Test".LastIndexOfAny(new[] { 't' });
5151
"Test".LastIndexOfAny(new[] { 't' }, 1);
5252
"Test".LastIndexOfAny(new[] { 't' }, 1, 3);
53-
"Test".Substring(1).LastIndexOfAny(new[] { 't' }); // Noncompliant {{Replace 'LastIndexOfAny' with the overload that accepts an offset parameter.}}
53+
"Test".Substring(1).LastIndexOfAny(new[] { 't' }); // Noncompliant {{Replace 'LastIndexOfAny' with the overload that accepts a startIndex parameter.}}
5454
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5555

5656
x.Substring(1).IndexOf('t'); // Noncompliant

0 commit comments

Comments
 (0)