openrewrite / openrewrite/rewrite-analysis
GlobalDataFlow - support qualified static variables
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 16
- Forks
- 12
- Avg merge
- 2h 26m
- Merged PRs (30d)
- 1
Description
What problem are you trying to solve?
I need to modify parts of the project based on the state of String literals that are scattered around the code-base. Ideally there would be a guarantee that any 'sink' traces back to a value that is immutable. I don't fully understand the code behind the GlobalDataFlow accumulator, but it does seem to cover quite a few of our case. However, it does not seem to work (at least in the way we expect it when a sink deals with a qualified constant (e.g. Constants.FOO).
Initially discussed here.
I have a similar use-case for enums, but I'll create a separate issue for that.
Have you considered any alternatives or workarounds?
For (public) constants, it's kind of easy to find those via a Scanning Recipe; however, there is an issue with tracking access if not public. Same for enums. But I haven't been able to solve a 'method chain' back to them, which I believe is one of the fundamental purposes of GlobalDataFlow.
Are you interested in contributing this feature to OpenRewrite?
Minimally, I'll create a test case. I have been trying to debug the code, but I'm not sure yet where the best place to work on this is. I can see that's it not going in as an 'edge', but not sure if that would be even appropriate.. Is the 'edge' the class, the qualified constant or neither:)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the GlobalDataFlow accumulator and the existing handling for sinks and qualified constants, then reproduce the Constants.FOO case described in the issue and linked discussion. Add the promised test case and verify that qualified static variables are traced as intended without regressing existing data-flow behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100