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:
parent
2721d6e6e5
commit
bf1fb6e84b
@ -611,13 +611,22 @@ dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
flutter_lints: ^1.0.3
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
|
||||||
// Import the analysis options from the Flutter root.
|
// 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'));
|
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.
|
/// 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...'));
|
..removeWhere((String line) => line.startsWith('Analyzer output:') || line.startsWith('Building flutter tool...'));
|
||||||
expect(process.exitCode, isNot(equals(0)));
|
expect(process.exitCode, isNot(equals(0)));
|
||||||
expect(stderrLines, <String>[
|
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),',
|
'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)",
|
">>> 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(',
|
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:30:9: new Opacity(',
|
||||||
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
||||||
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:62:9: new Opacity(',
|
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:62:9: new Opacity(',
|
||||||
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
'>>> 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';",
|
"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)',
|
'>>> 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;',
|
'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)',
|
'>>> 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;',
|
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:112:25: final int foo = null;',
|
||||||
|
@ -390,8 +390,9 @@ class DataCell {
|
|||||||
/// (int index) => DataRow(
|
/// (int index) => DataRow(
|
||||||
/// color: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
/// color: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||||
/// // All rows will have the same selected color.
|
/// // All rows will have the same selected color.
|
||||||
/// if (states.contains(MaterialState.selected))
|
/// if (states.contains(MaterialState.selected)) {
|
||||||
/// return Theme.of(context).colorScheme.primary.withOpacity(0.08);
|
/// return Theme.of(context).colorScheme.primary.withOpacity(0.08);
|
||||||
|
/// }
|
||||||
/// // Even rows will have a grey color.
|
/// // Even rows will have a grey color.
|
||||||
/// if (index.isEven) {
|
/// if (index.isEven) {
|
||||||
/// return Colors.grey.withOpacity(0.3);
|
/// return Colors.grey.withOpacity(0.3);
|
||||||
|
@ -260,8 +260,9 @@ typedef DecoderCallback = Future<ui.Codec> Function(Uint8List bytes, {int? cache
|
|||||||
/// @override
|
/// @override
|
||||||
/// void didUpdateWidget(MyImage oldWidget) {
|
/// void didUpdateWidget(MyImage oldWidget) {
|
||||||
/// super.didUpdateWidget(oldWidget);
|
/// super.didUpdateWidget(oldWidget);
|
||||||
/// if (widget.imageProvider != oldWidget.imageProvider)
|
/// if (widget.imageProvider != oldWidget.imageProvider) {
|
||||||
/// _getImage();
|
/// _getImage();
|
||||||
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// void _getImage() {
|
/// void _getImage() {
|
||||||
@ -545,8 +546,9 @@ abstract class ImageProvider<T extends Object> {
|
|||||||
/// void evictImage() {
|
/// void evictImage() {
|
||||||
/// final NetworkImage provider = NetworkImage(url);
|
/// final NetworkImage provider = NetworkImage(url);
|
||||||
/// provider.evict().then<void>((bool success) {
|
/// provider.evict().then<void>((bool success) {
|
||||||
/// if (success)
|
/// if (success) {
|
||||||
/// debugPrint('removed image!');
|
/// debugPrint('removed image!');
|
||||||
|
/// }
|
||||||
/// });
|
/// });
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
@ -153,8 +153,9 @@ const double _kLowDprLimit = 2.0;
|
|||||||
/// @override
|
/// @override
|
||||||
/// void didUpdateWidget(MyImage oldWidget) {
|
/// void didUpdateWidget(MyImage oldWidget) {
|
||||||
/// super.didUpdateWidget(oldWidget);
|
/// super.didUpdateWidget(oldWidget);
|
||||||
/// if (widget.assetImage != oldWidget.assetImage)
|
/// if (widget.assetImage != oldWidget.assetImage) {
|
||||||
/// _getImage();
|
/// _getImage();
|
||||||
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// void _getImage() {
|
/// void _getImage() {
|
||||||
|
@ -235,8 +235,9 @@ class _ActiveItem implements Comparable<_ActiveItem> {
|
|||||||
/// @override
|
/// @override
|
||||||
/// Widget build(BuildContext context) {
|
/// Widget build(BuildContext context) {
|
||||||
/// TextStyle textStyle = Theme.of(context).textTheme.headline4!;
|
/// TextStyle textStyle = Theme.of(context).textTheme.headline4!;
|
||||||
/// if (selected)
|
/// if (selected) {
|
||||||
/// textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]);
|
/// textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]);
|
||||||
|
/// }
|
||||||
/// return Padding(
|
/// return Padding(
|
||||||
/// padding: const EdgeInsets.all(2.0),
|
/// padding: const EdgeInsets.all(2.0),
|
||||||
/// child: SizeTransition(
|
/// child: SizeTransition(
|
||||||
|
@ -6162,8 +6162,9 @@ class RawImage extends LeafRenderObjectWidget {
|
|||||||
/// class TestAssetBundle extends CachingAssetBundle {
|
/// class TestAssetBundle extends CachingAssetBundle {
|
||||||
/// @override
|
/// @override
|
||||||
/// Future<ByteData> load(String key) async {
|
/// Future<ByteData> load(String key) async {
|
||||||
/// if (key == 'resources/test')
|
/// if (key == 'resources/test') {
|
||||||
/// return ByteData.view(Uint8List.fromList(utf8.encode('Hello World!')).buffer);
|
/// return ByteData.view(Uint8List.fromList(utf8.encode('Hello World!')).buffer);
|
||||||
|
/// }
|
||||||
/// return ByteData(0);
|
/// return ByteData(0);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
@ -75,8 +75,9 @@ import 'restoration.dart';
|
|||||||
///
|
///
|
||||||
/// @override
|
/// @override
|
||||||
/// void didUpdateValue(Duration? oldValue) {
|
/// void didUpdateValue(Duration? oldValue) {
|
||||||
/// if (oldValue == null || oldValue.inMicroseconds != value.inMicroseconds)
|
/// if (oldValue == null || oldValue.inMicroseconds != value.inMicroseconds) {
|
||||||
/// notifyListeners();
|
/// notifyListeners();
|
||||||
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// @override
|
/// @override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user