openrewrite / openrewrite/rewrite-static-analysis
Enhance InstanceOfPatternMatch to cover method invocations as well
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Java
- Stars
- 62
- Forks
- 112
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 40
Description
What problem are you trying to solve?
I've come across
if (authentication.getPrincipal() instanceof UserDetails) {
UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
return springSecurityUser.getUsername();
}
which is currently not covered
Describe the solution you'd like
if (authentication.getPrincipal() instanceof UserDetails springSecurityUser) {
return springSecurityUser.getUsername();
}
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 locating the InstanceOfPatternMatch recipe and its existing tests, then inspect how it handles instanceof expressions involving local variables. Add coverage for the authentication.getPrincipal() method-invocation example and verify that the transformation produces pattern matching with the bound UserDetails variable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100