-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-refactoringIssues with analysis server refactoringsIssues with analysis server refactoringstype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
This was originally raised at Dart-Code/Dart-Code#5373 by @stephane-archer.
If you extract code that sets a variable, it becomes a return value for the extracted method. The original variable is also passed as an argument, even if it has never been read in the extracted code and could just be declared inside the new function.
For example:
void f() {
int? i;
i = 1; // extract this line
print(i);
}Becomes:
void f() {
int? i;
i = g(i);
print(i);
}
int? g(int? i) {
i = 1;
return i;
}But since i is not read by the extracted method (only written), the parameter could be dropped and instead the variable just declared inside the extracted function:
void f() {
int? i;
i = g();
print(i);
}
int? g() {
int? i = 1;
return i;
}stephane-archer and FMorschelstephane-archer
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-refactoringIssues with analysis server refactoringsIssues with analysis server refactoringstype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug