Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ dotnet_diagnostic.CA1846.severity = warning
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1847
dotnet_diagnostic.CA1847.severity = warning

# CA1858: Use 'StartsWith' instead of 'IndexOf'
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1858
dotnet_diagnostic.CA1858.severity = warning

# CA1868: Unnecessary call to 'Contains' for sets
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1868
dotnet_diagnostic.CA1868.severity = warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ protected override void ProcessRecord()
byte[] iv = null;

// If this is a V2 package
if (String.IndexOf(SecureStringHelper.SecureStringExportHeader,
StringComparison.OrdinalIgnoreCase) == 0)
if (String.StartsWith(SecureStringHelper.SecureStringExportHeader, StringComparison.OrdinalIgnoreCase))
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8286,7 +8286,7 @@ internal static void DeleteFileStream(string path, string streamName)
ArgumentNullException.ThrowIfNull(streamName);

string adjustedStreamName = streamName.Trim();
if (adjustedStreamName.IndexOf(':') != 0)
if (!adjustedStreamName.StartsWith(':'))
{
adjustedStreamName = ":" + adjustedStreamName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4539,7 +4539,7 @@ internal static bool IsHomePath(string path)
}
}

if (path.IndexOf(StringLiterals.HomePath, StringComparison.Ordinal) == 0)
if (path.StartsWith(StringLiterals.HomePath, StringComparison.Ordinal))
{
// Support the single "~"
if (path.Length == 1)
Expand Down Expand Up @@ -4638,7 +4638,7 @@ internal string GetHomeRelativePath(string path)
}
}

if (path.IndexOf(StringLiterals.HomePath, StringComparison.Ordinal) == 0)
if (path.StartsWith(StringLiterals.HomePath, StringComparison.Ordinal))
{
// Strip of the ~ and the \ or / if present

Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/security/Authenticode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ internal static Signature SignFile(SigningOption option,
if (!string.IsNullOrEmpty(timeStampServerUrl))
{
if ((timeStampServerUrl.Length <= 7) || (
(timeStampServerUrl.IndexOf("http://", StringComparison.OrdinalIgnoreCase) != 0) &&
(timeStampServerUrl.IndexOf("https://", StringComparison.OrdinalIgnoreCase) != 0)))
!timeStampServerUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
!timeStampServerUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
{
throw PSTraceSource.NewArgumentException(
nameof(certificate),
Expand Down
Loading