Eliminate analysis warnings in pkg/ code.
Change-Id: I571581bf16502c1698932c03313777aa8a9ee081
Reviewed-on: https://dart-review.googlesource.com/63983
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart b/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart
index 47bdf9f..b835a7a 100644
--- a/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart
+++ b/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart
@@ -109,7 +109,7 @@
Map<dynamic, YamlNode> _getDeclaredDependencies(
ErrorReporter reporter, Map<dynamic, YamlNode> contents, String key) {
YamlNode field = contents[key];
- if (field == null) {
+ if (field == null || (field is YamlScalar && field.value == null)) {
return <String, YamlNode>{};
} else if (field is YamlMap) {
return field.nodes;
diff --git a/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart b/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart
index f4eb228..f841d78 100644
--- a/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart
+++ b/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart
@@ -53,6 +53,25 @@
validator = new PubspecValidator(resourceProvider, source);
}
+ test_assetDirectoryDoesExists_noError() {
+ newFolder('/sample/assets/logos');
+ assertNoErrors('''
+name: sample
+flutter:
+ assets:
+ - assets/logos/
+''');
+ }
+
+ test_assetDirectoryDoesNotExist_error() {
+ assertErrors('''
+name: sample
+flutter:
+ assets:
+ - assets/logos/
+''', [PubspecWarningCode.ASSET_DIRECTORY_DOES_NOT_EXIST]);
+ }
+
test_assetDoesNotExist_path_error() {
assertErrors('''
name: sample
@@ -159,44 +178,10 @@
''');
}
- test_assetDirectoryDoesNotExist_error() {
- assertErrors('''
-name: sample
-flutter:
- assets:
- - assets/logos/
-''', [PubspecWarningCode.ASSET_DIRECTORY_DOES_NOT_EXIST]);
- }
-
- test_assetDirectoryDoesExists_noError() {
- newFolder('/sample/assets/logos');
+ test_dependenciesField_empty() {
assertNoErrors('''
name: sample
-flutter:
- assets:
- - assets/logos/
-''');
- }
-
- test_dependenciesFieldNotMap_dev_error_bool() {
- assertErrors('''
-name: sample
-dev_dependencies: true
-''', [PubspecWarningCode.DEPENDENCIES_FIELD_NOT_MAP]);
- }
-
- test_dependenciesFieldNotMap_dev_error_empty() {
- assertErrors('''
-name: sample
-dev_dependencies:
-''', [PubspecWarningCode.DEPENDENCIES_FIELD_NOT_MAP]);
- }
-
- test_dependenciesFieldNotMap_dev_noError() {
- assertNoErrors('''
-name: sample
-dev_dependencies:
- a: any
+dependencies:
''');
}
@@ -207,13 +192,6 @@
''', [PubspecWarningCode.DEPENDENCIES_FIELD_NOT_MAP]);
}
- test_dependenciesFieldNotMap_error_empty() {
- assertErrors('''
-name: sample
-dependencies:
-''', [PubspecWarningCode.DEPENDENCIES_FIELD_NOT_MAP]);
- }
-
test_dependenciesFieldNotMap_noError() {
assertNoErrors('''
name: sample
@@ -222,11 +200,26 @@
''');
}
- test_flutterFieldNotMap_error_bool() {
+ test_devDependenciesField_empty() {
+ assertNoErrors('''
+name: sample
+dev_dependencies:
+''');
+ }
+
+ test_devDependenciesFieldNotMap_dev_error_bool() {
assertErrors('''
name: sample
-flutter: true
-''', [PubspecWarningCode.FLUTTER_FIELD_NOT_MAP]);
+dev_dependencies: true
+''', [PubspecWarningCode.DEPENDENCIES_FIELD_NOT_MAP]);
+ }
+
+ test_devDependenciesFieldNotMap_dev_noError() {
+ assertNoErrors('''
+name: sample
+dev_dependencies:
+ a: any
+''');
}
test_flutterField_empty_noError() {
@@ -242,6 +235,13 @@
''');
}
+ test_flutterFieldNotMap_error_bool() {
+ assertErrors('''
+name: sample
+flutter: true
+''', [PubspecWarningCode.FLUTTER_FIELD_NOT_MAP]);
+ }
+
test_flutterFieldNotMap_noError() {
newFile('/sample/assets/my_icon.png');
assertNoErrors('''
diff --git a/pkg/dart_messages/bin/publish.dart b/pkg/dart_messages/bin/publish.dart
index 2b609e6..60bc818 100644
--- a/pkg/dart_messages/bin/publish.dart
+++ b/pkg/dart_messages/bin/publish.dart
@@ -128,7 +128,7 @@
out.write(escapeExampleContent(example));
} else if (example is Map) {
out.writeln(" const {");
- example.forEach((String fileName, String content) {
+ example.forEach((fileName, content) {
out.writeln(" '$fileName': ");
out.write(escapeExampleContent(content));
out.writeln(",");
diff --git a/pkg/dev_compiler/analysis_options.yaml b/pkg/dev_compiler/analysis_options.yaml
index 2b52428..55db4c5 100644
--- a/pkg/dev_compiler/analysis_options.yaml
+++ b/pkg/dev_compiler/analysis_options.yaml
@@ -1,10 +1,9 @@
analyzer:
- strong-mode: true
exclude:
- doc/api/**
- gen/**
- node_modules/**
- - tool/input_sdk/**
- test/codegen/**
- test/samples/**
- test/transformer/hello_app/**
+ - tool/input_sdk/**
diff --git a/pkg/dev_compiler/pubspec.yaml b/pkg/dev_compiler/pubspec.yaml
new file mode 100644
index 0000000..86d997a
--- /dev/null
+++ b/pkg/dev_compiler/pubspec.yaml
@@ -0,0 +1 @@
+name: dev_compiler
diff --git a/pkg/status_file/analysis_options.yaml b/pkg/status_file/analysis_options.yaml
index 3acdae1..b5516058 100644
--- a/pkg/status_file/analysis_options.yaml
+++ b/pkg/status_file/analysis_options.yaml
@@ -3,8 +3,6 @@
# BSD-style license that can be found in the LICENSE file.
analyzer:
- strong-mode: true
errors:
# Allow having TODOs in the code
todo: ignore
- uses_dynamic_as_bottom: ignore
\ No newline at end of file
diff --git a/tools/gardening/analysis_options.yaml b/tools/gardening/analysis_options.yaml
index 3acdae1..b5516058 100644
--- a/tools/gardening/analysis_options.yaml
+++ b/tools/gardening/analysis_options.yaml
@@ -3,8 +3,6 @@
# BSD-style license that can be found in the LICENSE file.
analyzer:
- strong-mode: true
errors:
# Allow having TODOs in the code
todo: ignore
- uses_dynamic_as_bottom: ignore
\ No newline at end of file