Unverified Commit cae740b9 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Enable strict-casts (as replacement for implicit-casts) (#101567)

parent 3109073f
# Specify analysis options. # Specify analysis options.
# #
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/ # For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more # See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/main/pkg/analyzer#configuring-the-analyzer # https://github.com/dart-lang/sdk/tree/main/pkg/analyzer#configuring-the-analyzer
...@@ -15,11 +12,12 @@ ...@@ -15,11 +12,12 @@
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml # - https://github.com/flutter/engine/blob/master/analysis_options.yaml
# - https://github.com/flutter/packages/blob/master/analysis_options.yaml # - https://github.com/flutter/packages/blob/master/analysis_options.yaml
# #
# This file contains the analysis options used by Flutter tools, such as IntelliJ, # This file contains the analysis options used for code in the flutter/flutter
# Android Studio, and the `flutter analyze` command. # repository.
analyzer: analyzer:
language: language:
strict-casts: true
strict-raw-types: true strict-raw-types: true
errors: errors:
# treat missing required parameters as a warning (not a hint) # treat missing required parameters as a warning (not a hint)
...@@ -43,8 +41,7 @@ analyzer: ...@@ -43,8 +41,7 @@ analyzer:
linter: linter:
rules: rules:
# these rules are documented on and in the same order as # This list is derived from the list of all available lints located at
# the Dart Lint rules page to make maintenance easier
# https://github.com/dart-lang/linter/blob/master/example/all.yaml # https://github.com/dart-lang/linter/blob/master/example/all.yaml
- always_declare_return_types - always_declare_return_types
- always_put_control_body_on_new_line - always_put_control_body_on_new_line
......
...@@ -1735,7 +1735,7 @@ class TextInput { ...@@ -1735,7 +1735,7 @@ class TextInput {
final Map<String, dynamic> encoded = args[1] as Map<String, dynamic>; final Map<String, dynamic> encoded = args[1] as Map<String, dynamic>;
for (final dynamic encodedDelta in encoded['deltas']) { for (final dynamic encodedDelta in encoded['deltas'] as List<dynamic>) {
final TextEditingDelta delta = TextEditingDelta.fromJSON(encodedDelta as Map<String, dynamic>); final TextEditingDelta delta = TextEditingDelta.fromJSON(encodedDelta as Map<String, dynamic>);
deltas.add(delta); deltas.add(delta);
} }
......
...@@ -234,7 +234,7 @@ class DeferredComponentsGenSnapshotValidator extends DeferredComponentsValidator ...@@ -234,7 +234,7 @@ class DeferredComponentsGenSnapshotValidator extends DeferredComponentsValidator
return loadingUnits; return loadingUnits;
} }
if (data['loading-units'] != null) { if (data['loading-units'] != null) {
for (final Object? loadingUnitData in data['loading-units']) { for (final Object? loadingUnitData in data['loading-units'] as List<Object?>) {
if (loadingUnitData is! YamlMap) { if (loadingUnitData is! YamlMap) {
invalidFiles[cacheFile.path] = "Invalid loading units yaml file, 'loading-units' " invalidFiles[cacheFile.path] = "Invalid loading units yaml file, 'loading-units' "
'is not a list of maps.'; 'is not a list of maps.';
...@@ -267,7 +267,7 @@ class DeferredComponentsGenSnapshotValidator extends DeferredComponentsValidator ...@@ -267,7 +267,7 @@ class DeferredComponentsGenSnapshotValidator extends DeferredComponentsValidator
// Parse out validated yaml. // Parse out validated yaml.
if (data.containsKey('loading-units')) { if (data.containsKey('loading-units')) {
if (data['loading-units'] != null) { if (data['loading-units'] != null) {
for (final Object? loadingUnitData in data['loading-units']) { for (final Object? loadingUnitData in data['loading-units'] as List<Object?>) {
final YamlMap? loadingUnitDataMap = loadingUnitData as YamlMap?; final YamlMap? loadingUnitDataMap = loadingUnitData as YamlMap?;
final List<String> libraries = <String>[]; final List<String> libraries = <String>[];
final YamlList? nodes = loadingUnitDataMap?['libraries'] as YamlList?; final YamlList? nodes = loadingUnitDataMap?['libraries'] as YamlList?;
......
...@@ -195,7 +195,7 @@ class LoadingUnit { ...@@ -195,7 +195,7 @@ class LoadingUnit {
final List<LoadingUnit> loadingUnits = <LoadingUnit>[]; final List<LoadingUnit> loadingUnits = <LoadingUnit>[];
// Setup android source directory // Setup android source directory
if (manifest != null) { if (manifest != null) {
for (final dynamic loadingUnitMetadata in manifest['loadingUnits']) { for (final dynamic loadingUnitMetadata in manifest['loadingUnits'] as List<dynamic>) {
final Map<String, dynamic> loadingUnitMap = loadingUnitMetadata as Map<String, dynamic>; final Map<String, dynamic> loadingUnitMap = loadingUnitMetadata as Map<String, dynamic>;
if (loadingUnitMap['id'] == 1) { if (loadingUnitMap['id'] == 1) {
continue; // Skip base unit continue; // Skip base unit
......
...@@ -636,7 +636,7 @@ void _validateFonts(YamlList fonts, List<String> errors) { ...@@ -636,7 +636,7 @@ void _validateFonts(YamlList fonts, List<String> errors) {
errors.add('Expected "fonts" to either be null or a list.'); errors.add('Expected "fonts" to either be null or a list.');
continue; continue;
} }
for (final Object? fontMapList in fontMap['fonts']) { for (final Object? fontMapList in fontMap['fonts'] as List<Object?>) {
if (fontMapList is! YamlMap) { if (fontMapList is! YamlMap) {
errors.add('Expected "fonts" to be a list of maps.'); errors.add('Expected "fonts" to be a list of maps.');
continue; continue;
......
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