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

False positive for NON_STATIC_PATTERN_COMPILE_CALL #21

Open
boris-petrov opened this issue Jun 15, 2017 · 0 comments
Open

False positive for NON_STATIC_PATTERN_COMPILE_CALL #21

boris-petrov opened this issue Jun 15, 2017 · 0 comments

Comments

@boris-petrov
Copy link

I have something like:

public final class RegexHelpers {
	private RegexHelpers() {
	}

	public static Pattern getUnescapedSymbolPattern(char symbol) {
		return Pattern.compile(getUnescapedSymbolRegex(symbol));
	}

	public static String getUnescapedSymbolRegex(char symbol) {
		String escapedSymbol = Pattern.quote(String.valueOf(symbol));
		return "(^|[^\\\\])(\\\\\\\\)*" + escapedSymbol; // (^|[^\\])(\\\\)*,
	}
}

Which gives a NON_STATIC_PATTERN_COMPILE_CALL.

I also have another case of a false positive in code like:

	private boolean propertyMatchesText(String test, String text, boolean shouldMatchWholeString) {
		String pcre = SomeHelpers.textToPcre(text, shouldMatchWholeString);
		int caseInsensitiveFlag = isCaseInsensitive() ? Pattern.CASE_INSENSITIVE : 0;
		Pattern pattern = Pattern.compile(pcre, caseInsensitiveFlag | Pattern.UNICODE_CASE);
		return pattern.matcher(test).find();
	}
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

1 participant