diff --git a/analysis_options.yaml b/analysis_options.yaml index 37f1c95755..60c9bf7d1e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,6 +1,9 @@ analyzer: - strong-mode: - implicit-dynamic: false + language: + # strict-casts: true 11 issues found + strict-inference: true + strict-raw-types: true + errors: # treat missing required parameters as a warning (not a hint) missing_required_param: warning @@ -20,12 +23,9 @@ analyzer: linter: rules: - # See all available options here - # https://github.com/dart-lang/linter/blob/master/example/all.yaml + # See all available options at https://dart.dev/lints - always_declare_return_types - always_put_control_body_on_new_line - - - always_require_non_null_named_parameters - annotate_overrides - avoid_empty_else - avoid_field_initializers_in_const_classes @@ -70,7 +70,6 @@ linter: - prefer_const_declarations - prefer_const_literals_to_create_immutables - prefer_contains - - prefer_equal_for_default_values - prefer_final_fields - prefer_final_locals - prefer_foreach diff --git a/lib/config/config.dart b/lib/config/config.dart index 9ac513c968..3b21b6409f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -174,7 +174,7 @@ class Config { final MacOSConfig? macOSConfig; /// Creates [Config] icons from [json] - factory Config.fromJson(Map json) => _$ConfigFromJson(json); + factory Config.fromJson(Map json) => _$ConfigFromJson(json); /// whether or not there is configuration for adaptive icons for android bool get hasAndroidAdaptiveConfig => diff --git a/lib/config/config.g.dart b/lib/config/config.g.dart index 5087f1846d..97dabf1bcd 100644 --- a/lib/config/config.g.dart +++ b/lib/config/config.g.dart @@ -23,8 +23,9 @@ Config _$ConfigFromJson(Map json) => $checkedCreate( 'image_path_ios_tinted_grayscale', (v) => v as String?), adaptiveIconForeground: $checkedConvert('adaptive_icon_foreground', (v) => v as String?), - adaptiveIconForegroundInset: - $checkedConvert('adaptive_icon_foreground_inset', (v) => v as int? ?? 16), + adaptiveIconForegroundInset: $checkedConvert( + 'adaptive_icon_foreground_inset', + (v) => (v as num?)?.toInt() ?? 16), adaptiveIconBackground: $checkedConvert('adaptive_icon_background', (v) => v as String?), adaptiveIconMonochrome: diff --git a/lib/config/macos_config.dart b/lib/config/macos_config.dart index ee267efb64..07d37b10d7 100644 --- a/lib/config/macos_config.dart +++ b/lib/config/macos_config.dart @@ -23,7 +23,8 @@ class MacOSConfig { }); /// Creates [WebConfig] from [json] - factory MacOSConfig.fromJson(Map json) => _$MacOSConfigFromJson(json); + factory MacOSConfig.fromJson(Map json) => + _$MacOSConfigFromJson(json); /// Creates [Map] from [WebConfig] Map toJson() => _$MacOSConfigToJson(this); diff --git a/lib/config/web_config.dart b/lib/config/web_config.dart index c0130375c3..ddeeb87083 100644 --- a/lib/config/web_config.dart +++ b/lib/config/web_config.dart @@ -32,7 +32,8 @@ class WebConfig { }); /// Creates [WebConfig] from [json] - factory WebConfig.fromJson(Map json) => _$WebConfigFromJson(json); + factory WebConfig.fromJson(Map json) => + _$WebConfigFromJson(json); /// Creates [Map] from [WebConfig] Map toJson() => _$WebConfigToJson(this); diff --git a/lib/config/windows_config.dart b/lib/config/windows_config.dart index 0c94e2e585..819701089f 100644 --- a/lib/config/windows_config.dart +++ b/lib/config/windows_config.dart @@ -27,10 +27,11 @@ class WindowsConfig { }); /// Creates [WindowsConfig] from [json] - factory WindowsConfig.fromJson(Map json) => _$WindowsConfigFromJson(json); + factory WindowsConfig.fromJson(Map json) => + _$WindowsConfigFromJson(json); /// Creates [Map] from [WindowsConfig] - Map toJson() => _$WindowsConfigToJson(this); + Map toJson() => _$WindowsConfigToJson(this); @override String toString() => 'WindowsConfig: ${toJson()}'; diff --git a/lib/pubspec_parser.dart b/lib/pubspec_parser.dart index c8b33819bc..3d5ce481b1 100644 --- a/lib/pubspec_parser.dart +++ b/lib/pubspec_parser.dart @@ -9,10 +9,10 @@ class PubspecParser { PubspecParser._(); /// parses the pubspec located at [path] to map - static Map fromPathToMap(String path) { + static Map fromPathToMap(String path) { final File file = File(path); final String yamlString = file.readAsStringSync(); - final Map yamlMap = loadYaml(yamlString); + final Map yamlMap = loadYaml(yamlString); return yamlMap; } } diff --git a/test/abs/icon_generator_test.mocks.dart b/test/abs/icon_generator_test.mocks.dart index 8d60d4b125..3d349591ee 100644 --- a/test/abs/icon_generator_test.mocks.dart +++ b/test/abs/icon_generator_test.mocks.dart @@ -40,6 +40,12 @@ class MockConfig extends _i1.Mock implements _i3.Config { _i1.throwOnMissingStub(this); } + @override + int get adaptiveIconForegroundInset => (super.noSuchMethod( + Invocation.getter(#adaptiveIconForegroundInset), + returnValue: 0, + ) as int); + @override int get minSdkAndroid => (super.noSuchMethod( Invocation.getter(#minSdkAndroid), diff --git a/test/macos/macos_icon_generator_test.mocks.dart b/test/macos/macos_icon_generator_test.mocks.dart index 47b5dc9128..be401029fa 100644 --- a/test/macos/macos_icon_generator_test.mocks.dart +++ b/test/macos/macos_icon_generator_test.mocks.dart @@ -47,6 +47,13 @@ class _FakeProgress_1 extends _i1.SmartFake implements _i2.Progress { /// /// See the documentation for Mockito's code generation for more information. class MockConfig extends _i1.Mock implements _i3.Config { + @override + int get adaptiveIconForegroundInset => (super.noSuchMethod( + Invocation.getter(#adaptiveIconForegroundInset), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + @override int get minSdkAndroid => (super.noSuchMethod( Invocation.getter(#minSdkAndroid), diff --git a/test/windows/windows_icon_generator_test.mocks.dart b/test/windows/windows_icon_generator_test.mocks.dart index 9cd13510eb..17ed3f784f 100644 --- a/test/windows/windows_icon_generator_test.mocks.dart +++ b/test/windows/windows_icon_generator_test.mocks.dart @@ -51,6 +51,12 @@ class MockConfig extends _i1.Mock implements _i3.Config { _i1.throwOnMissingStub(this); } + @override + int get adaptiveIconForegroundInset => (super.noSuchMethod( + Invocation.getter(#adaptiveIconForegroundInset), + returnValue: 0, + ) as int); + @override int get minSdkAndroid => (super.noSuchMethod( Invocation.getter(#minSdkAndroid), @@ -157,13 +163,13 @@ class MockWindowsConfig extends _i1.Mock implements _i5.WindowsConfig { ) as bool); @override - Map toJson() => (super.noSuchMethod( + Map toJson() => (super.noSuchMethod( Invocation.method( #toJson, [], ), - returnValue: {}, - ) as Map); + returnValue: {}, + ) as Map); } /// A class which mocks [FLILogger].