-
Notifications
You must be signed in to change notification settings - Fork 15
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
Prevents jvm incompat dataclass constructors with value class params #329
Prevents jvm incompat dataclass constructors with value class params #329
Conversation
f252e0e
to
7116c3f
Compare
* To prevent issues like xebia-functional#275, dataclasses must not use parameters that are value classes without a `JvmStatic` factory method in their companion object.
7116c3f
to
c92c7e9
Compare
...kt-rules/src/main/kotlin/org/example/detekt/PublicDataClassConstructorWithValueParameters.kt
Outdated
Show resolved
Hide resolved
...ules/src/test/kotlin/org/example/detekt/PublicDataClassConstructorWithValueParametersTest.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Jack!
After looking over the files, it seems at first sight all issues here are related to the use of the value
class.
If that is the case we need a rule to disallow using value
classes.
I think the rule for static companion factories is unnecessary, and in main, we now have instances of multiple cases where the Prompt
class, a data class, is called from Java to any of its constructors.
Can we have a single rule to disallow value
instead of 2 rules?
We can. It would also result in a change to RequestConfig that would not be source compatible, if that's acceptable. My intention with these lints is to be as non-invasive as possible to the declared api to avoid disruption of the current pace of development. If we don't mind me changing the signature of RequestConfig and potentially call sites (I think 11, currently), the current two Lint riles can be collapsed to a single rule disallowin value classes in common and jvm source sets. I can address this very quickly, just give me a 👍 on this comment. It should be noted, if the concern is additional rules, we will need additional rules anyway:
In addition we need rules for avoiding the creation of public common and jvm apis relying on kotlin annotations, which cannot be called as annotations from scala. We can achieve the same effect by declaring jvm annotations in a Java class for the jvm, and platform specific annotations and processors can be declared for the other multiplatform source sets. Currently, only Finally, I intend to ensure all platforms have equivalent examples, which may reveal additional required lint rules. |
...kt-rules/src/main/kotlin/org/example/detekt/PublicDataClassConstructorWithValueParameters.kt
Outdated
Show resolved
Hide resolved
…sConstructorWithValueParameters.kt
We can make those changes to |
Bump to trigger workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you Jack!
that are value classes without a
JvmStatic
factory method in theircompanion object.