Why this matters
Using re.sub() when no regex features are needed is inefficient. str.replace() is faster and should be used for simple string replacements.
str.replace() Over re.sub() for Simple CasesDetect uses of re.sub() where regular expressions are not needed. For simple string replacements, str.replace() is more efficient and should be used instead.
Using re.sub() when no regex features are needed is inefficient. str.replace() is faster and should be used for simple string replacements.
Side-by-side examples engineers can pattern-match during review.
init = "Bob is a Bird... Bob is a Plane... Bob is Superman!"
changed = re.sub(r"Bob is", "It's", init) # Noncompliant
changed = re.sub(r"\.\.\.", ";", changed) # Noncompliantinit = "Bob is a Bird... Bob is a Plane... Bob is Superman!"
changed = init.replace("Bob is", "It's")
changed = changed.replace("...", ";")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.