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