Commit e77b186a authored by Michael R Fairhurst's avatar Michael R Fairhurst Committed by Devon Carew

Enable lint unnecessary_statements. Codebase is compliant. (#20099)

* Enable lint unnecessary_statements. Codebase is compliant.

* Fix mega_gallery generated code to not generate unecessary statements

* Fix lint in mega gallery changes

* Enable unnecessary_statements for users as well as repo.
parent b81e3611
...@@ -150,7 +150,7 @@ linter: ...@@ -150,7 +150,7 @@ linter:
- unnecessary_null_in_if_null_operators - unnecessary_null_in_if_null_operators
- unnecessary_overrides - unnecessary_overrides
- unnecessary_parenthesis - unnecessary_parenthesis
# - unnecessary_statements # not yet tested - unnecessary_statements
- unnecessary_this - unnecessary_this
- unrelated_type_equality_checks - unrelated_type_equality_checks
- use_rethrow_when_possible - use_rethrow_when_possible
......
...@@ -92,11 +92,10 @@ void main(List<String> args) { ...@@ -92,11 +92,10 @@ void main(List<String> args) {
// TODO(devoncarew): Create an entry-point that builds a UI with all `n` copies. // TODO(devoncarew): Create an entry-point that builds a UI with all `n` copies.
void _createEntry(File mainFile, int copies) { void _createEntry(File mainFile, int copies) {
final StringBuffer imports = new StringBuffer(); final StringBuffer imports = new StringBuffer();
final StringBuffer importRefs = new StringBuffer();
for (int i = 1; i < copies; i++) { for (int i = 1; i < copies; i++) {
imports.writeln('// ignore: unused_import');
imports.writeln("import 'gallery_$i/main.dart' as main_$i;"); imports.writeln("import 'gallery_$i/main.dart' as main_$i;");
importRefs.writeln(' main_$i.main;');
} }
final String contents = ''' final String contents = '''
...@@ -110,9 +109,6 @@ import 'gallery/app.dart'; ...@@ -110,9 +109,6 @@ import 'gallery/app.dart';
${imports.toString().trim()} ${imports.toString().trim()}
void main() { void main() {
// Make sure the imports are not marked as unused.
${importRefs.toString().trim()}
runApp(const GalleryApp()); runApp(const GalleryApp());
} }
'''; ''';
......
...@@ -81,5 +81,6 @@ linter: ...@@ -81,5 +81,6 @@ linter:
# - unawaited_futures # - unawaited_futures
- unnecessary_brace_in_string_interps - unnecessary_brace_in_string_interps
- unnecessary_getters_setters - unnecessary_getters_setters
- unnecessary_statements
- unrelated_type_equality_checks - unrelated_type_equality_checks
- valid_regexps - valid_regexps
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment