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

Add MethodAccessSystemGetProperty predicate #4898

Merged
merged 3 commits into from
Jan 5, 2021

Conversation

JLLeitschuh
Copy link
Contributor

This simple predicate looks for calls to System.getProperty with a compile time constant.

This pattern is pretty common. As an example: https://lgtm.com/query/1737527738205752665/

This PR is a dependency for both #4388 & #4473

@JLLeitschuh JLLeitschuh requested a review from a team as a code owner January 2, 2021 01:26
@github-actions github-actions bot added the Java label Jan 2, 2021
@@ -16,5 +16,6 @@ class PrintAstConfigurationOverride extends PrintAstConfiguration {
/**
* TWEAK THIS PREDICATE AS NEEDED.
*/
override predicate shouldPrint(Element e, Location l) { super.shouldPrint(e, l) }
override predicate shouldPrint(Element e, Location l) { super.shouldPrint(e, l) and
not l.getFile().getBaseName().matches("SystemGetPropertyCall.java") }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally committed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is intentional. Do you want me to just update the test result?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please update the test result instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be resolved now.

MethodAccessSystemGetProperty() { getMethod() instanceof MethodSystemGetProperty }

/**
* Holds true if this is a compile-time constant call for the specified `propertyName`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Holds true if this is a compile-time constant call for the specified `propertyName`.
* Holds true if this call gets a compile-time constant property `propertyName`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is resolved.

@smowton smowton self-assigned this Jan 4, 2021
@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/system_get_property branch from 99c0ef1 to ba4a562 Compare January 5, 2021 04:38
@JLLeitschuh
Copy link
Contributor Author

This should be ready for another review pass. 😄

Thanks for the quick turnarround on feedback!

@aschackmull aschackmull merged commit 26a9ba4 into github:main Jan 5, 2021
@JLLeitschuh JLLeitschuh deleted the feat/JLL/system_get_property branch January 5, 2021 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants