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

[java] FormalParameterNamingConventions should accept unnamed parameters by default #5028

Closed
cowwoc opened this issue May 21, 2024 · 0 comments · Fixed by #5004
Closed

[java] FormalParameterNamingConventions should accept unnamed parameters by default #5028

cowwoc opened this issue May 21, 2024 · 0 comments · Fixed by #5004
Labels
an:enhancement An improvement on existing features / rules
Milestone

Comments

@cowwoc
Copy link

cowwoc commented May 21, 2024

Is your feature request related to a problem? Please describe.
https://openjdk.org/jeps/456 (Java 22) added unnamed variables denoted by _ (underscore)

Rule: FormalParameterNamingConventions

Describe the solution you'd like
FormalParameterNamingConventions should accept _ as a valid name by default. Currently it complains The lambda parameter name '_' doesn't match '[a-z][a-zA-Z0-9]*'.

Describe alternatives you've considered

I'm using the following workaround:

<rule ref="category/java/codestyle.xml/FormalParameterNamingConventions">
	<properties>
		<property name="methodParameterPattern" value="_|[a-z][a-zA-Z0-9]*"/>
		<property name="finalMethodParameterPattern" value="_|[a-z][a-zA-Z0-9]*"/>
		<property name="lambdaParameterPattern" value="_|[a-z][a-zA-Z0-9]*"/>
		<property name="explicitLambdaParameterPattern" value="_|[a-z][a-zA-Z0-9]*"/>
	</properties>
</rule>
@cowwoc cowwoc added the an:enhancement An improvement on existing features / rules label May 21, 2024
@cowwoc cowwoc changed the title [java] FormalParameterNamingConventions should accept _ parameter by default [java] FormalParameterNamingConventions should accept unnamed parameters by default May 21, 2024
@oowekyala oowekyala linked a pull request May 21, 2024 that will close this issue
4 tasks
@jsotuyod jsotuyod added this to the 7.2.0 milestone May 21, 2024
adangel added a commit to oowekyala/pmd that referenced this issue May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
an:enhancement An improvement on existing features / rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants