Why this matters
Searching for characters within a substring without a start index can lead to inefficiency and unnecessary memory usage.
Verify that when extracting substrings, a start index is specified to avoid unnecessary memory allocations.
Searching for characters within a substring without a start index can lead to inefficiency and unnecessary memory usage.
Side-by-side examples engineers can pattern-match during review.
if (str.SubString(startIndex).IndexOf(char1) == -1) // Noncompliant: a new string is going to be created by "Substring"
{
// ...
}if (str.IndexOf(char1, startIndex) == -1) // Compliant: no new instance of string is created
{
// ...
}if (str.SubString(startIndex).IndexOf(char1) == -1) // Noncompliant: a new string is going to be created by "Substring"
{
// ...
}if (str.IndexOf(char1, startIndex) == -1) // Compliant: no new instance of string is created
{
// ...
}From the same buckets as this rule.
All static JS/CSS/font/image files MUST use content-hashed filenames (e.g., app.9c1a7b.js) and be served with "Cache-Control: public, max-age=31536000, immutable". HTML and other non-fingerprinted documents MUST be served with "Cache-Control: no-cache" (or equivalent) to enable conditional revalidation.