-
Notifications
You must be signed in to change notification settings - Fork 507
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
Naming rules should allow keywords to be wrapped between backticks #2352
Comments
Duplicate of #2339 |
This is not a duplicate of that issue. You cannot remove the backticks here as the name is otherwise a keyword. Backticks are required to use spaces but it is certainly not their only use. |
Indeed, you can not remove the backticks here. According to Kotlin coding conventions:
So when you read above literally, it would allow the example code above as a kind of helper method inside a Test class. But, from the Kotlin coding conventions it is quite clear that it is meant for functions annotated with |
Right. So this issue should be reopened as there are valid, non-test-based uses of backticks. If you are overriding a Java method whose name is a Kotlin keyword, or you need to provide binary compatibility with a previous version of a library which used a Kotlin keyword as a function or property name they are necessary and should not be flagged. |
I'd agree with @JakeWharton , also this issue is only appear on this version. |
In my specific case, I have a property named "package": val `package` = type.names[0] It represents a package, so that's what I named it. The failing rule says
It does start with a lowercase "p" and use camel case. The backticks are not part of the name. The backticks allow me to tell the compiler's parser that I am producing a variable name and not a hard keyword. |
Thank you! |
Expected Behavior
Function name with backticks and short name should not throwing an error when formatting.
Observed Behavior
Ktlint detect function name with backticks wrongly for example if I have method like in the following :
when I format the code it would throw an error like the following :
[ktlint] /Users/dsetyawan/Documents/pAPI/spring-kotlin-demo/src/main/kotlin/com/example/springkotlindemo/SpringKotlinDemoApplication.kt:13:5: Function name should start with a lowercase letter (except factory methods) and use camel case (standard:function-naming)
Steps to Reproduce
Clone my example project : https://github.com/dimasadryantos/spring-kotlin-demo/tree/master
Run :
mvn clean compile
orktlint --format
Your Environment
The text was updated successfully, but these errors were encountered: