Skip to content

Instantly share code, notes, and snippets.

@dnwe
Created November 30, 2020 12:34
Show Gist options
  • Save dnwe/3c979dd0d4c4a5497a206ca7021ac7a2 to your computer and use it in GitHub Desktop.
Save dnwe/3c979dd0d4c4a5497a206ca7021ac7a2 to your computer and use it in GitHub Desktop.
Java semgrep for String#replaceAll("...", "...")
rules:
- id: java.lang.string.replaceall-is-slow
message: |
Look out for invocations of regexp mehods like String#replaceAll("...", "...") on hot code paths.
Compiling into a reusable Pattern instance is almost always the preferable option.
severity: WARNING
patterns:
- pattern-either:
- pattern: |-
$STRING.replaceAll("...", "...")
languages:
- java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment