diff --git a/jsonexample/analysis_options.yaml b/jsonexample/analysis_options.yaml new file mode 100644 index 000000000..a8e1f7b52 --- /dev/null +++ b/jsonexample/analysis_options.yaml @@ -0,0 +1,32 @@ +include: package:pedantic/analysis_options.yaml + +analyzer: + exclude: + - lib/json_serializable/*.g.dart + strong-mode: + implicit-casts: false + implicit-dynamic: false + +linter: + rules: + - avoid_types_on_closure_parameters + - avoid_void_async + - await_only_futures + - camel_case_types + - cancel_subscriptions + - close_sinks + - constant_identifier_names + - control_flow_in_finally + - empty_statements + - hash_and_equals + - implementation_imports + - non_constant_identifier_names + - package_api_docs + - package_names + - package_prefixed_library_names + - test_types_in_equals + - throw_in_finally + - unnecessary_brace_in_string_interps + - unnecessary_getters_setters + - unnecessary_new + - unnecessary_statements diff --git a/jsonexample/lib/built_value/built_complex_object.dart b/jsonexample/lib/built_value/built_complex_object.dart index ef337cd9d..0670df8c6 100644 --- a/jsonexample/lib/built_value/built_complex_object.dart +++ b/jsonexample/lib/built_value/built_complex_object.dart @@ -40,6 +40,7 @@ abstract class BuiltComplexObject BuiltComplexObject._(); - factory BuiltComplexObject([updates(BuiltComplexObjectBuilder b)]) = + factory BuiltComplexObject( + [void Function(BuiltComplexObjectBuilder) updates]) = _$BuiltComplexObject; } diff --git a/jsonexample/lib/built_value/built_simple_object.dart b/jsonexample/lib/built_value/built_simple_object.dart index 84dee0a4e..1ff84be0d 100644 --- a/jsonexample/lib/built_value/built_simple_object.dart +++ b/jsonexample/lib/built_value/built_simple_object.dart @@ -33,6 +33,6 @@ abstract class BuiltSimpleObject BuiltSimpleObject._(); - factory BuiltSimpleObject([updates(BuiltSimpleObjectBuilder b)]) = + factory BuiltSimpleObject([void Function(BuiltSimpleObjectBuilder) updates]) = _$BuiltSimpleObject; } diff --git a/jsonexample/lib/dart_convert/converted_complex_object.dart b/jsonexample/lib/dart_convert/converted_complex_object.dart index 526ebc17f..adb073785 100644 --- a/jsonexample/lib/dart_convert/converted_complex_object.dart +++ b/jsonexample/lib/dart_convert/converted_complex_object.dart @@ -29,24 +29,27 @@ class ConvertedComplexObject { if (json == null) return null; return ConvertedComplexObject( - aString: json['aString'], - anInt: json['anInt'], - aDouble: json['aDouble'], + aString: json['aString'] as String, + anInt: json['anInt'] as int, + aDouble: json['aDouble'] as double, anObject: json['anObject'] != null - ? ConvertedSimpleObject.fromJson(json['anObject']) + ? ConvertedSimpleObject.fromJson( + json['anObject'] as Map) : null, aListOfStrings: json['aListOfStrings'] != null - ? List.from(json['aListOfStrings']) + ? List.from(json['aListOfStrings'] as Iterable) : null, aListOfInts: json['aListOfInts'] != null - ? List.from(json['aListOfInts']) + ? List.from(json['aListOfInts'] as Iterable) : null, aListOfDoubles: json['aListOfDoubles'] != null - ? List.from(json['aListOfDoubles']) + ? List.from(json['aListOfDoubles'] as Iterable) : null, aListOfObjects: json['aListOfObjects'] != null - ? List.from(json['aListOfObjects'] - .map((o) => ConvertedSimpleObject.fromJson(o))) + ? List.from((json['aListOfObjects'] + as Iterable) + .map((dynamic o) => + ConvertedSimpleObject.fromJson(o as Map))) : null); } } diff --git a/jsonexample/lib/dart_convert/converted_simple_object.dart b/jsonexample/lib/dart_convert/converted_simple_object.dart index 6f8b1771f..a9611841d 100644 --- a/jsonexample/lib/dart_convert/converted_simple_object.dart +++ b/jsonexample/lib/dart_convert/converted_simple_object.dart @@ -23,17 +23,17 @@ class ConvertedSimpleObject { if (json == null) return null; return ConvertedSimpleObject( - aString: json['aString'], - anInt: json['anInt'], - aDouble: json['aDouble'], + aString: json['aString'] as String, + anInt: json['anInt'] as int, + aDouble: json['aDouble'] as double, aListOfStrings: json['aListOfStrings'] != null - ? List.from(json['aListOfStrings']) + ? List.from(json['aListOfStrings'] as Iterable) : null, aListOfInts: json['aListOfInts'] != null - ? List.from(json['aListOfInts']) + ? List.from(json['aListOfInts'] as Iterable) : null, aListOfDoubles: json['aListOfDoubles'] != null - ? List.from(json['aListOfDoubles']) + ? List.from(json['aListOfDoubles'] as Iterable) : null, ); } diff --git a/jsonexample/lib/tab_pages.dart b/jsonexample/lib/tab_pages.dart index 590f1bc43..c1fd3aa54 100644 --- a/jsonexample/lib/tab_pages.dart +++ b/jsonexample/lib/tab_pages.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: argument_type_not_assignable, strong_mode_implicit_dynamic_parameter, strong_mode_implicit_dynamic_variable + import 'dart:convert'; import 'package:flutter/material.dart'; diff --git a/jsonexample/lib/widgets.dart b/jsonexample/lib/widgets.dart index 40bdde2a5..999651b93 100644 --- a/jsonexample/lib/widgets.dart +++ b/jsonexample/lib/widgets.dart @@ -58,7 +58,7 @@ class SimpleObjectView extends StatelessWidget { Text('aListOfStrings:', style: boldStyle), Text( prettyPrintList( - simpleObject.aListOfStrings, + simpleObject.aListOfStrings as Iterable, ), style: localTheme.body1, ), @@ -68,7 +68,7 @@ class SimpleObjectView extends StatelessWidget { children: [ Text('aListOfInts:', style: boldStyle), Text( - prettyPrintList(simpleObject.aListOfInts), + prettyPrintList(simpleObject.aListOfInts as Iterable), style: localTheme.body1, ), ], @@ -80,7 +80,7 @@ class SimpleObjectView extends StatelessWidget { child: Text('aListOfDoubles:', style: boldStyle), ), Text( - prettyPrintList(simpleObject.aListOfDoubles), + prettyPrintList(simpleObject.aListOfDoubles as Iterable), style: localTheme.body1, ), ], @@ -135,7 +135,7 @@ class ComplexObjectView extends StatelessWidget { ]; } - if (simpleObjects.length == 0) { + if (simpleObjects.isEmpty) { return [ const Padding( padding: EdgeInsets.symmetric(vertical: 4.0), @@ -145,7 +145,7 @@ class ComplexObjectView extends StatelessWidget { } return simpleObjects - .expand((o) => [ + .expand((dynamic o) => [ const SizedBox(height: 4.0), SimpleObjectView(o), const SizedBox(height: 4.0), @@ -213,7 +213,8 @@ class ComplexObjectView extends StatelessWidget { children: [ Text('aListOfStrings:', style: boldStyle), Text( - prettyPrintList(complexObject.aListOfStrings), + prettyPrintList( + complexObject.aListOfStrings as Iterable), style: localTheme.body1, ), ], @@ -222,7 +223,8 @@ class ComplexObjectView extends StatelessWidget { children: [ Text('aListOfInts:', style: boldStyle), Text( - prettyPrintList(complexObject.aListOfInts), + prettyPrintList( + complexObject.aListOfInts as Iterable), style: localTheme.body1, ), ], @@ -234,7 +236,8 @@ class ComplexObjectView extends StatelessWidget { child: Text('aListOfDoubles:', style: boldStyle), ), Text( - prettyPrintList(complexObject.aListOfDoubles), + prettyPrintList( + complexObject.aListOfDoubles as Iterable), style: localTheme.body1, ), ], @@ -251,8 +254,8 @@ class ComplexObjectView extends StatelessWidget { padding: const EdgeInsets.only(left: 24.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: - _generateSimpleObjectWidgets(complexObject.aListOfObjects), + children: _generateSimpleObjectWidgets( + complexObject.aListOfObjects as Iterable), ), ), ], diff --git a/jsonexample/pubspec.lock b/jsonexample/pubspec.lock index 71fd27cca..c999a5d3f 100644 --- a/jsonexample/pubspec.lock +++ b/jsonexample/pubspec.lock @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" boolean_selector: dependency: transitive description: @@ -299,7 +299,7 @@ packages: source: hosted version: "1.6.2" pedantic: - dependency: transitive + dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" @@ -332,7 +332,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" shelf: dependency: transitive description: @@ -407,7 +407,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.4" + version: "0.2.5" timing: dependency: transitive description: diff --git a/jsonexample/pubspec.yaml b/jsonexample/pubspec.yaml index adad5aaa4..cdcc34cf3 100644 --- a/jsonexample/pubspec.yaml +++ b/jsonexample/pubspec.yaml @@ -16,6 +16,7 @@ dev_dependencies: build_runner: ^1.0.0 built_value_generator: ^6.1.5 json_serializable: ^2.2.1 + pedantic: ^1.5.0 flutter_test: sdk: flutter diff --git a/jsonexample/test/simple_object_unit_test.dart b/jsonexample/test/simple_object_unit_test.dart index 9a19f813f..2c1bfcffb 100644 --- a/jsonexample/test/simple_object_unit_test.dart +++ b/jsonexample/test/simple_object_unit_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: strong_mode_implicit_dynamic_list_literal + import 'package:flutter_test/flutter_test.dart'; import 'package:jsonexample/built_value/built_simple_object.dart'; import 'package:jsonexample/built_value/built_value_serializers.dart'; diff --git a/jsonexample/test/widget_tests_test.dart b/jsonexample/test/widget_tests_test.dart index 6b1e3f87e..cc3f79de9 100644 --- a/jsonexample/test/widget_tests_test.dart +++ b/jsonexample/test/widget_tests_test.dart @@ -10,8 +10,7 @@ import 'package:jsonexample/widgets.dart'; void main() { group('SimpleObjectView widget test', () { - testWidgets('Typical object is displayed correctly', - (WidgetTester tester) async { + testWidgets('Typical object is displayed correctly', (tester) async { final simpleObject = ConvertedSimpleObject( aString: 'Blah, blah, blah', anInt: 1, @@ -35,8 +34,7 @@ void main() { expect(find.text('[1.0, 2.0, 3.0]'), findsOneWidget); }); - testWidgets('Empty lists are displayed as brackets', - (WidgetTester tester) async { + testWidgets('Empty lists are displayed as brackets', (tester) async { final simpleObject = ConvertedSimpleObject( aString: 'Blah, blah, blah', anInt: 1, @@ -55,8 +53,7 @@ void main() { expect(find.text('[]'), findsNWidgets(3)); }); - testWidgets('Null values are displayed as NULL', - (WidgetTester tester) async { + testWidgets('Null values are displayed as NULL', (tester) async { final simpleObject = ConvertedSimpleObject( aString: null, anInt: null, @@ -77,8 +74,7 @@ void main() { }); group('ComplexObjectView widget test', () { - testWidgets('Typical object is displayed correctly', - (WidgetTester tester) async { + testWidgets('Typical object is displayed correctly', (tester) async { final complexObject = ConvertedComplexObject( aString: 'Blah, blah, blah', anInt: 1, @@ -145,8 +141,7 @@ void main() { } }); - testWidgets('Empty lists are displayed as brackets', - (WidgetTester tester) async { + testWidgets('Empty lists are displayed as brackets', (tester) async { final complexObject = ConvertedComplexObject( aString: 'Blah, blah, blah', anInt: 1, @@ -174,8 +169,7 @@ void main() { expect(find.text('[]'), findsNWidgets(4)); }); - testWidgets('Null values are displayed as NULL', - (WidgetTester tester) async { + testWidgets('Null values are displayed as NULL', (tester) async { final complexObject = ConvertedComplexObject( aString: null, anInt: null,