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

Fix: Add test for keyword usage in method names (#426) #490

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lakshaybxt
Copy link

What's changed?

Added a test case to verify that method names using the this_ identifier are correctly handled without renaming.

What's your motivation?

This fixes issue #426 by ensuring methods with this_ in their name are not renamed incorrectly.

Anything in particular you'd like reviewers to focus on?

Please check if the test case covers all edge cases for keyword-like method names.

Anyone you would like to review specifically?

@openrewrite/reviewers @maintainers

Have you considered any alternatives or workarounds?

An alternative was modifying the recipe logic, but adding a test case was a simpler and more effective solution.

Any additional context

This test ensures future changes do not introduce regressions.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 29, 2025
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Good to see the test added, thanks! Did you already explore how to fix the failing test?

@@ -505,6 +505,29 @@ private void method() {
);
}

@Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/426") // Links to the issue being tested
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
@Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/426") // Links to the issue being tested
@Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/426")

void keywordUsage() {
rewriteRun(
srcMainJava(
// Language hint for syntax highlighting
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
// Language hint for syntax highlighting

@timtebeek timtebeek added the bug Something isn't working label Mar 29, 2025
@timtebeek timtebeek marked this pull request as draft March 29, 2025 19:26
@lakshaybxt lakshaybxt marked this pull request as ready for review March 30, 2025 04:52
@timtebeek timtebeek marked this pull request as draft March 30, 2025 07:19
@timtebeek
Copy link
Contributor

We have a convention of only marking PRs ready for review when they are close to being merged. Since the implementation is missing we'll keep this as draft for now.

@lakshaybxt
Copy link
Author

lakshaybxt commented Apr 3, 2025

I fixed the changes, is the changes show in this pull request only or I have to raise a new one?

@lakshaybxt lakshaybxt marked this pull request as ready for review April 3, 2025 05:01
@greg-at-moderne
Copy link
Contributor

I fixed the changes, is the changes show in this pull request only or I have to raise a new one?

No need to raise another one, but make sure to push your code changes to your branch (426-keyword-usage in your fork).
`

@lakshaybxt
Copy link
Author

Thanks for the help, @greg-at-moderne! I've pushed it to my branch.

@timtebeek
Copy link
Contributor

We're not yet seeing the fix you made on the branch underlying this pull request:
https://github.com/lakshaybxt/rewrite-static-analysis/tree/fix/426-keyword-usage

Note that we should be seeing your recipe code changes here before we can review:
https://github.com/openrewrite/rewrite-static-analysis/pull/490/files

@lakshaybxt
Copy link
Author

Sorry for the issue. Now I commit the fixes to my branch and I'm grateful for your help.
https://github.com/lakshaybxt/rewrite-static-analysis/blob/fix/426-keyword-usage/src/test/java/org/openrewrite/staticanalysis/MethodNameCasingTest.java

@timtebeek
Copy link
Contributor

That's good ; now we see the changes to the test class reflected here. Did you already explore a fix to the recipe class itself? That would be necessary before we can merge.

@timtebeek timtebeek marked this pull request as draft April 3, 2025 18:18
@lakshaybxt
Copy link
Author

lakshaybxt commented Apr 3, 2025

I'm working on it and can you help me on this? Like what I have to do
It is showing this "Cannot find a Java installation on your machine (Windows 11 10.0 amd64) matching: {languageVersion=21, vendor=any vendor, implementation=vendor-specific}. Toolchain download repositories have not been configured.

Possible solutions:

  • Install required toolchain
  • Modify Daemon JVM criteria
    "
    Problem

@greg-at-moderne
Copy link
Contributor

If you don't have experience with Java development, IntelliJ, running tests, etc. I suggest you find some courses (or use materials from ChatGPT) to start with. And only then proceed to address an issue like this.
This way you can learn and gain new skills.

@timtebeek
Copy link
Contributor

As to the IDE warnings above you'll want to go through these pages:

But indeed, if you're not yet comfortable developing, then it might help to try your hand at some easier projects first. Not meant to discourage, but we've known this project not to be easy for folks starting out, and have limited time to help you on your way.

@lakshaybxt
Copy link
Author

Thanks for the advice I really appreciate it. I might need more hands-on practice on some basic projects as you suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants