Skip to content

Conversation

@pstreef
Copy link
Contributor

@pstreef pstreef commented Oct 22, 2023

Many frameworks depend on method argument names to use for request parameter names or json field names. By renaming these without knowing how the frameworks use these we can make breaking changes. It's better to do no change.

What's changed?

Non camel case names are kept in method argument names.

What's your motivation?

Do no harm

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

isMethodArgument()

Anyone you would like to review specifically?

@joanvr @timtebeek

Have you considered any alternatives or workarounds?

no

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've added the license header to any new files through ./gradlew licenseFormat
  • I've used the IntelliJ IDEA auto-formatter on affected files (No because it adds much extra indentation to the test file. I think that's not wanted?)

…est parameter names or json field names. By renaming these without knowing how the frameworks use these we can make breaking changes. It's better to do no change.
@pstreef pstreef requested review from joanvr and timtebeek October 22, 2023 18:14
Copy link
Contributor

@joanvr joanvr left a comment

Choose a reason for hiding this comment

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

I'm not a big fan of removing the method parameters capability of the recipe, but for now seems the most sensitive thing to do if we cannot narrow it a bit more based on som anotations...

rewriteRun(
java(
"""
@Controller
Copy link
Contributor

Choose a reason for hiding this comment

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

Are those anotations needed for the test? They are not imported anyway, thus giving incomplete type attribution... maybe we could remove them for simplicity.

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 added them to show give a more in-depth example of why this is added. I bet most people here recognise which annotations I mean with this.

I did not think the type attribution was worth adding spring as a dependency though.

Although perhaps I should change it to just have an @Issue annotation that explains the why?

Copy link
Contributor

Choose a reason for hiding this comment

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

Note: Soon we will flag these missing type attributions in before sources as errors (unless the before type validation is configured to ignore these).

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, reference this issue from the test too. As Knut says, we have plans to fail tests that do not have proper type attribution in the before step...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

}

@SuppressWarnings("JavadocDeclaration")
@Disabled
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

@pstreef pstreef merged commit a4ea014 into main Oct 23, 2023
@pstreef pstreef deleted the fix/do-not-rename-method-arguments branch October 23, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants