You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
data classDemo(valvalue:String) {
companionobject {
funfrom(string:String?): Demo?=Demo(string ?:returnnull)
}
}
Expected behavior
Ditkat does not rewrite the above code, because it is not valid Kotlin to use the return keyword when a function is a single expression. The single expression function body is necessary to support the null input case.
Observed behavior
Diktat rewrites the code causing a compilation error
Steps to Reproduce
Write any function body which consists of a single expression but uses patterns like ?: return foo which would not be supported as a single expression function
Adding any comment inside the function body stops diktat from rewriting the code, but this is not ideal since there is not always a need for such a comment.
Environment information
diktat version: 1.2.1
build tool (maven/gradle): gradle
how is diktat run (CLI, plugin, etc.): spotless (spotlessApply task)
kotlin version: 1.7.10
operating system: macOS
link to a project (if your project is public): NA
The text was updated successfully, but these errors were encountered:
Describe the bug
Diktat rewrites the following code:
into
Expected behavior
Ditkat does not rewrite the above code, because it is not valid Kotlin to use the return keyword when a function is a single expression. The single expression function body is necessary to support the null input case.
Observed behavior
Diktat rewrites the code causing a compilation error
Steps to Reproduce
Write any function body which consists of a single expression but uses patterns like
?: return foo
which would not be supported as a single expression functionAdding any comment inside the function body stops diktat from rewriting the code, but this is not ideal since there is not always a need for such a comment.
Environment information
The text was updated successfully, but these errors were encountered: