rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

Improve naming: Change `boolean1` to `bool` and standardize fields

Open Pankraz76 opened this issue 9 months ago • 6 comments

The boolean1 name looks kind of off to me because of the text chars and number mix matching.
Is it mandatory because there's the need for numerous fields, so the counting is necessary (which I'm not aware of at the moment)?

I'm assuming not, as the other fields don't have a counter as well.

So I would prefer, suggest, and expect something similar and precise with only alphabetic chars and not numbers - like bool or maybe even boolean_.

Code Example 1 Code Example 2

https://github.com/quarkusio/quarkus/pull/47303 Source/Reproduce: https://docs.openrewrite.org/recipes/java/migrate/upgradetojava17

Pankraz76 avatar Apr 11 '25 07:04 Pankraz76

Proposal: Adopt Kotlin-style it convention for single parameters

I suggest implementing a functional/generic it approach for single parameters, following Kotlin's implicit naming convention. While not identical, this shares the same core philosophy of concise (lambda) expressions.

Reference:
Kotlin Lambdas: it - implicit name of a single parameter

Benefits:

  • More concise functional-style code
  • Consistent with modern language conventions
  • Reduces unnecessary parameter naming
  • Maintains readability while being succinct
Example showing lambda usage with implicit 'it' parameter

Pankraz76 avatar Apr 11 '25 07:04 Pankraz76

Prefer clazz or clazz1 over class1 as this is more common imho:

https://stackoverflow.com/questions/2529974/why-do-java-programmers-like-to-name-a-variable-clazz https://dpericich.medium.com/what-is-the-difference-between-class-klass-and-clazz-416b7d2736c1 https://commons.apache.org/dormant/clazz/userguide.html

Image Image

Pankraz76 avatar Apr 11 '25 08:04 Pankraz76

hi! You've logged this as a bug, but I suppose it's a suggestion for a new recipe, correct?

timtebeek avatar Apr 11 '25 08:04 timtebeek

Hi tim,

Yes imho its questionable behavior of a recepie we need to figure out yet as always like approached broadly via major migration: https://docs.openrewrite.org/recipes/java/migrate/upgradetojava17

So its no new stuff as the whole pr https://github.com/quarkusio/quarkus/pull/47303 is done by rewrite.

I've only adjusted the class name offset. from class1 to clazz like what we should adjust as well imho.

If we go fully rockstar with the generic it approach is an different much more invasive and a change (feature) but not a fix like the class naming.

Pankraz76 avatar Apr 11 '25 09:04 Pankraz76

Ah thanks for that context; I think that naming is defined here: https://github.com/openrewrite/rewrite/blob/cd4a37fcbf4ea33229cac6c868991ee2e0ef711e/rewrite-java/src/main/java/org/openrewrite/java/service/JavaNamingService.java#L28-L66

timtebeek avatar Apr 11 '25 14:04 timtebeek

This issue is stale because it has not had any activity for 60 days. Remove question label or comment or this will be closed in two weeks. Issues may be reopened when there is renewed interest.

github-actions[bot] avatar Jul 28 '25 11:07 github-actions[bot]