[linter, DAS] Adds `simplify_variable_pattern` lint and fix
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
I love this! Nice impl, and a long overdue lint rule.
DeclaredVariablePattern variablePattern;This could be:
```
var pattern = node.pattern;
if (pattern is! DeclaredVariablePattern) return;
```
late AstNode node;I might be crazy, but I can't see where this field is used.
DeclaredVariablePattern variablePattern;I find these 6 lines a little round-about. We could just do:
```
var pattern = node.pattern;
if (pattern is! DeclaredVariablePattern) return;
```
String _accessor(PatternField field) => switch (field.parent) {At some point I'm just playing code golf, apologies. But seeing all the cases that lead to 'field', I'm thinking this could just look like:
```
switch (field.parent) {
ObjectPattern(element: MethodElement()) => 'method',
ObjectPattern(element: GetterElement()) => 'getter',
_ => 'field',
};
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This will need to be updated in order for it to be landed.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Hmm, hopefully the tools now generate the right file? Should you delete this and rerun... something? Paul has been doing a lot of refactor work here.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
This could be:
```
var pattern = node.pattern;
if (pattern is! DeclaredVariablePattern) return;
```
Hmm, hopefully the tools now generate the right file? Should you delete this and rerun... something? Paul has been doing a lot of refactor work here.
This was with the new tools. Although I've opened https://github.com/dart-lang/sdk/issues/62220.
Is there anything else I should do differently?
I might be crazy, but I can't see where this field is used.
Oops! Probably left from my first tries hahaha. Thanks!
I find these 6 lines a little round-about. We could just do:
```
var pattern = node.pattern;
if (pattern is! DeclaredVariablePattern) return;
```
Done
String _accessor(PatternField field) => switch (field.parent) {At some point I'm just playing code golf, apologies. But seeing all the cases that lead to 'field', I'm thinking this could just look like:
```
switch (field.parent) {
ObjectPattern(element: MethodElement()) => 'method',
ObjectPattern(element: GetterElement()) => 'getter',
_ => 'field',
};
```
Thanks for the suggestion! Not quite the syntax but it helped!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Felipe MorschelHmm, hopefully the tools now generate the right file? Should you delete this and rerun... something? Paul has been doing a lot of refactor work here.
This was with the new tools. Although I've opened https://github.com/dart-lang/sdk/issues/62220.
Is there anything else I should do differently?
Ah my bad. When I use Gerrit to compare Patchset 1 with Patchset 3, it says you added 4400 lines to diagnostic.g.dart, lol. But I see now what happened. All is good.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
Fixed the missing entries. Everything should pass now. Thanks for the bots!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
stable: "3.0"I think this is supposed to be '3.11'.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
stable: "3.0"I think this is supposed to be '3.11'.
I forgot to change this now. I wasn't sure what version this would land. AFK now, I'll send a new patch later. Thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
stable: "3.0"Felipe MorschelI think this is supposed to be '3.11'.
I forgot to change this now. I wasn't sure what version this would land. AFK now, I'll send a new patch later. Thanks!
Lints always land, in some state, in the next release. We're currently at '3.11.0-edge', so the next release will be '3.11'.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
Felipe MorschelI think this is supposed to be '3.11'.
Brian WilkersonI forgot to change this now. I wasn't sure what version this would land. AFK now, I'll send a new patch later. Thanks!
Lints always land, in some state, in the next release. We're currently at '3.11.0-edge', so the next release will be '3.11'.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[linter, DAS] Adds `simplify_variable_pattern` lint and fix
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |