2fa07c6488
This CL adds a lint as part of the collection of lints used to automate converting code to use the features under the primary constructors flag. The lint flags initializers in a primary constructor body that initialize a field in such a way that the initialization could be done in the field declaration's initializer. It only flags assignments to fields where the right-hand side of the assignment includes a reference to one or more of the constructor's parameters. Expressions that don't reference a parameter would have been valid to move before primary constructors, so flagging them wouldn't help find bugs in the impementation of the feature. If we were going to ship this lint, then we might want to extend it to find initializers that don't reference parameters, whether they are in the primary constructor body's initializer list or in the initializer list of a secondary constructor. This doesn't include a fix. Once again, I wanted to make sure the lint was covering all the important cases before implementing the lint. Change-Id: Id4b1e02ec160af50af8f4fe7b8c675213e41abc7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502202 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Examples
Some example analysis options files.
- all.yaml - auto-generated options enabling all lints.
For more on lint rule sets see the analyzer docs on customizing static analysis.
Official Dart lint rules are maintained in
package:lints.
Flutter team rules are maintained in
package:flutter_lints.