-
Notifications
You must be signed in to change notification settings - Fork 93
RenameLocalVariablesToCamelCase: Do not rename method argument names. #205
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,9 @@ | |
| */ | ||
| package org.openrewrite.staticanalysis; | ||
|
|
||
| import org.junit.jupiter.api.Disabled; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junitpioneer.jupiter.ExpectedToFail; | ||
| import org.openrewrite.DocumentExample; | ||
| import org.openrewrite.Issue; | ||
| import org.openrewrite.Recipe; | ||
|
|
@@ -89,23 +91,23 @@ void renameLocalVariables() { | |
| class Test { | ||
| int DoNoTChange; | ||
|
|
||
| public int addTen(int rename_one) { | ||
| public int addTen(int dont_rename_one) { | ||
| double RenameTwo = 2.0; | ||
| float __rename__three__ = 2.0; | ||
| long _Rename__Four = 2.0; | ||
| return rename_one + RenameTwo + __rename__three__ + _Rename__Four + 10; | ||
| return dont_rename_one + RenameTwo + __rename__three__ + _Rename__Four + 10; | ||
| } | ||
| } | ||
| """, | ||
| """ | ||
| class Test { | ||
| int DoNoTChange; | ||
|
|
||
| public int addTen(int renameOne) { | ||
| public int addTen(int dont_rename_one) { | ||
| double renameTwo = 2.0; | ||
| float renameThree = 2.0; | ||
| long renameFour = 2.0; | ||
| return renameOne + renameTwo + renameThree + renameFour + 10; | ||
| return dont_rename_one + renameTwo + renameThree + renameFour + 10; | ||
| } | ||
| } | ||
| """ | ||
|
|
@@ -114,6 +116,7 @@ public int addTen(int renameOne) { | |
| } | ||
|
|
||
| @SuppressWarnings("JavadocDeclaration") | ||
| @Disabled | ||
| @Issue("https://github.com/openrewrite/rewrite/issues/2437") | ||
| @Test | ||
| void renameJavaDocParam() { | ||
|
|
@@ -438,6 +441,7 @@ void test() { | |
|
|
||
| @Test | ||
| void renameFinalLocalVariables() { | ||
| //language=java | ||
| rewriteRun( | ||
| java( | ||
| """ | ||
|
|
@@ -458,4 +462,22 @@ void test() { | |
| ); | ||
| } | ||
|
|
||
| @Test | ||
| void doNotRenameMethodArguments(){ | ||
| //language=java | ||
| rewriteRun( | ||
| java( | ||
| """ | ||
| @Controller | ||
|
||
| class MyController { | ||
| @GetMapping | ||
| String getHello(@RequestParam String your_name) { | ||
| return "hello " + your_name; | ||
| } | ||
| } | ||
| """ | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joanvr did you notice this? I've disabled this test since it fixed an issue that might be important if we ever decide to start (limited) support for renaming method args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could try to rename param references in annotations too? Although I'm not sure if we can have a generic enough approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but even if there is 1 annotation, it does not mean that it's always used only with that annotation. It's a slippery slope and there will likely still be cases where we could break something.