dart-code-metrics
dart-code-metrics copied to clipboard
[Rule change] When excluding files in `check-unnecessary-nullable`, such as `.g.dart`, should take their method *calls* into consideration, while ignoring methods *defined* there
What rule do you want to change?
Hi thanks for the wonderful package!
A very common example is json_serializable. We may have a class class A {final int? field; A(this.field); } that is json serializable. With excluding .g.dart, the linter warns that the field is unnecessarily null, while we all know it is meaningful to be nullable because it deserializes some data from the network which is often nullable in many specific use cases.
How will the change be implemented? (New option, new default behavior, etc.)?
Please provide some example code that this change will affect:
What does the rule currently do for this code?
What will the rule do after it's changed?
Are you willing to submit a pull request to implement this change?
That's interesting, this should be handled, will take a look
@fzyzcjy hm, looking closer to that and it seems that's an edge case. Could you provide the code example so I could write tests for it and correctly handle what needs to be excluded?
I also cannot provide a very good example without giving you a ton of code...
Anyway, I workaround by letting it output in json, and write down a python postprocessor to filter unneeded things. Thanks all the same!
A ton of code is alright for me, if it doesn't bother you to share. I think that's a valid use-case to be ignored, so a ton of code is not a blocker 😄
Well those code are not open-source yet :/ Anyway I will share if I later see it in my open source projects. Thanks :)
@fzyzcjy I'll close this for now. Feel free to reopen when you have an example