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
Create new check IllegalIdentifierName #8764
Comments
Can itbe done by https://checkstyle.org/config_naming.html#LocalVariableName by more advanced regexp ? |
|
Do we need another new check, We have LambdaParameterName, MemberName, and ParameterName. Since record components are basically "members", we should make it possible for users to enforce naming conventions on them. |
The list of keywords may expand when a new version of Java is released. |
Yes, existing |
We update default. |
Fix is merged. |
From #8308
Adding new keywords to a language is very difficult, since they are probably used as identifiers in the existing code. Our parser should accept such keyword as an identifier, but we need a new check. Something like
AvoidUsingKeywordsAsIdentifiers
.Originally posted by @pbludov in #8267 (comment)
From https://jaxenter.com/java-14-records-deep-dive-169879.html:
"However, you should refrain from using record as an identifier because it could be included as a keyword in a future Java version."
Java already issues the following errors:
So, the addition of this new check would help remind developers that it is bad practice to use context-sensitive/ restricted keywords as identifiers; this will help to make code more future-proof and easy to read. I would expect the following:
The text was updated successfully, but these errors were encountered: