Closed APXANGEL93 closed 5 months ago
So the autofix that has the issues in your case, right? And the detection fails in the navigation DSL?
Well, the triggering of the rule itself is also false. The dependency is passed to the screen explicitly in the constructor
Yeah the rule won't check the cases where the factory function is instantiated directly in a KtCallableReference's parameters, it will only check if they are being instantiated in a property.
I'm gonna to submit a fix that filters it out when it's instantiated inside a NavHost DSL, so those won't be reported. Also I'll get rid of the autofix if the factory function has params, as we can't be 100% sure it won't screw things up.
Let's say we have the following function:
although there is no default value, it is still correct. Here the rule works fine. Then we use it for example from the navigation declaration like this:
Here, too, everything works correctly. But then we decide to use assistedfactory to add parameters to the viewmodel and change the code like this:
This is where the rule sounds the alarm, although everything still remains correct. Let's go further and explicitly declare the type of the viewModel variable:
Here the rule finally loses its mind and it puts the variable with the viewmodel into the parameter of the function in which all the screens are located:
kotlin = "1.9.23" compose = "1.6.4" ktlint = "12.1.0" ktlintComposeRules = "0.3.12"