Switch sample analysis over to use package:flutter_lints (#84303)
This switches the sample analysis code to use package:flutter_lints instead of the flutter repo analysis options, so that they are compatible with a similar change to DartPad.
This commit is contained in:
@@ -611,13 +611,22 @@ dependencies:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_lints: ^1.0.3
|
||||
''');
|
||||
|
||||
|
||||
// Import the analysis options from the Flutter root.
|
||||
final File rootAnalysisOptions = File(path.join(_flutterRoot,'analysis_options.yaml'));
|
||||
final File analysisOptions = File(path.join(directory.path, 'analysis_options.yaml'));
|
||||
analysisOptions.writeAsStringSync('include: ${rootAnalysisOptions.absolute.path}');
|
||||
analysisOptions.writeAsStringSync('''
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
linter:
|
||||
rules:
|
||||
# Samples want to print things pretty often.
|
||||
avoid_print: false
|
||||
''');
|
||||
}
|
||||
|
||||
/// Writes out a sample section to the disk and returns the file.
|
||||
|
||||
@@ -24,22 +24,14 @@ void main() {
|
||||
..removeWhere((String line) => line.startsWith('Analyzer output:') || line.startsWith('Building flutter tool...'));
|
||||
expect(process.exitCode, isNot(equals(0)));
|
||||
expect(stderrLines, <String>[
|
||||
'In sample starting at dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:117:bool? _visible = true;',
|
||||
'>>> info: Use late for private members with non-nullable type (use_late_for_private_fields_and_variables)',
|
||||
'In sample starting at dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:117: child: Text(title),',
|
||||
">>> error: The final variable 'title' can't be read because it is potentially unassigned at this point (read_potentially_unassigned_final)",
|
||||
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:30:9: new Opacity(',
|
||||
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
||||
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:62:9: new Opacity(',
|
||||
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
||||
"dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:95:9: const text0 = Text('Poor wandering ones!');",
|
||||
'>>> info: Specify type annotations (always_specify_types)',
|
||||
"dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:103:9: const text1 = _Text('Poor wandering ones!');",
|
||||
'>>> info: Specify type annotations (always_specify_types)',
|
||||
"dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:111:9: final String? bar = 'Hello';",
|
||||
'>>> info: Prefer const over final for declarations (prefer_const_declarations)',
|
||||
"dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:111:23: final String? bar = 'Hello';",
|
||||
'>>> info: Use a non-nullable type for a final variable initialized with a non-nullable value (unnecessary_nullable_for_final_variable_declarations)',
|
||||
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:112:9: final int foo = null;',
|
||||
'>>> info: Prefer const over final for declarations (prefer_const_declarations)',
|
||||
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:112:25: final int foo = null;',
|
||||
|
||||
Reference in New Issue
Block a user