Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New performance rule for using String replace instead of replaceAll #705

Open
blindspeed90 opened this issue Jul 20, 2018 · 1 comment
Open

Comments

@blindspeed90
Copy link

People mistakenly use replaceAll as a literal replacement, and will get the overhead of doing a regexp. Possibly the code could check the parameter for the existence of any special regexp characters as its' test.

@lasselindqvist
Copy link
Contributor

Based on https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html it would make sense to warn if the replaceAll does not contain any letter from "\.[]{}()<>*+-=?^$|"

lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 8, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 9, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 9, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 9, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 10, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 10, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 10, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 14, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 15, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 19, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 21, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 23, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
lasselindqvist added a commit to lasselindqvist/spotbugs that referenced this issue Nov 23, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
KengoTODA pushed a commit that referenced this issue Nov 27, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
RahulNagekar pushed a commit to RahulNagekar/spotbugs that referenced this issue Dec 3, 2018
Implement new detector IRA_INEFFICIENT_REPLACEALL. Finds occurrences of replaceAll(String regex, String replacement) without any special regex characters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants