Skip to content

Commit 3c6d717

Browse files
committed
Merge remote-tracking branch 'google/master' into google#780
2 parents 35745a7 + 3bf4564 commit 3c6d717

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+337
-183
lines changed

Diff for: .github/workflows/dart.yml

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Created with package:mono_repo v3.4.6
1+
# Created with package:mono_repo v3.4.7
22
name: Dart CI
33
on:
44
push:
@@ -27,32 +27,32 @@ jobs:
2727
restore-keys: |
2828
os:ubuntu-latest;pub-cache-hosted
2929
os:ubuntu-latest
30-
- uses: dart-lang/setup-dart@v0.3
30+
- uses: dart-lang/setup-dart@v1.0
3131
with:
3232
sdk: stable
3333
- id: checkout
3434
uses: actions/checkout@v2
3535
- name: mono_repo self validate
36-
run: pub global activate mono_repo 3.4.6
36+
run: pub global activate mono_repo 3.4.7
3737
- name: mono_repo self validate
3838
run: pub global run mono_repo generate --validate
3939
job_002:
40-
name: "analyzer_and_format; Dart beta; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
40+
name: "analyzer_and_format; Dart 2.12.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
4141
runs-on: ubuntu-latest
4242
steps:
4343
- name: Cache Pub hosted dependencies
4444
uses: actions/cache@v2
4545
with:
4646
path: "~/.pub-cache/hosted"
47-
key: "os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:dartfmt-dartanalyzer"
47+
key: "os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:dartfmt-dartanalyzer"
4848
restore-keys: |
49-
os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable
50-
os:ubuntu-latest;pub-cache-hosted;dart:beta
49+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable
50+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0
5151
os:ubuntu-latest;pub-cache-hosted
5252
os:ubuntu-latest
53-
- uses: dart-lang/setup-dart@v0.3
53+
- uses: dart-lang/setup-dart@v1.0
5454
with:
55-
sdk: beta
55+
sdk: "2.12.0"
5656
- id: checkout
5757
uses: actions/checkout@v2
5858
- id: _test_yaml_pub_upgrade
@@ -134,7 +134,7 @@ jobs:
134134
os:ubuntu-latest;pub-cache-hosted;dart:dev
135135
os:ubuntu-latest;pub-cache-hosted
136136
os:ubuntu-latest
137-
- uses: dart-lang/setup-dart@v0.3
137+
- uses: dart-lang/setup-dart@v1.0
138138
with:
139139
sdk: dev
140140
- id: checkout
@@ -205,22 +205,22 @@ jobs:
205205
working-directory: json_serializable
206206
run: dartanalyzer --fatal-infos .
207207
job_004:
208-
name: "unit_test; Dart beta; PKGS: _test_yaml, checked_yaml, example, json_serializable; `pub run test`"
208+
name: "unit_test; Dart 2.12.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `pub run test`"
209209
runs-on: ubuntu-latest
210210
steps:
211211
- name: Cache Pub hosted dependencies
212212
uses: actions/cache@v2
213213
with:
214214
path: "~/.pub-cache/hosted"
215-
key: "os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0"
215+
key: "os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0"
216216
restore-keys: |
217-
os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:_test_yaml-checked_yaml-example-json_serializable
218-
os:ubuntu-latest;pub-cache-hosted;dart:beta
217+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:_test_yaml-checked_yaml-example-json_serializable
218+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0
219219
os:ubuntu-latest;pub-cache-hosted
220220
os:ubuntu-latest
221-
- uses: dart-lang/setup-dart@v0.3
221+
- uses: dart-lang/setup-dart@v1.0
222222
with:
223-
sdk: beta
223+
sdk: "2.12.0"
224224
- id: checkout
225225
uses: actions/checkout@v2
226226
- id: _test_yaml_pub_upgrade
@@ -277,7 +277,7 @@ jobs:
277277
os:ubuntu-latest;pub-cache-hosted;dart:dev
278278
os:ubuntu-latest;pub-cache-hosted
279279
os:ubuntu-latest
280-
- uses: dart-lang/setup-dart@v0.3
280+
- uses: dart-lang/setup-dart@v1.0
281281
with:
282282
sdk: dev
283283
- id: checkout
@@ -323,22 +323,22 @@ jobs:
323323
- job_002
324324
- job_003
325325
job_006:
326-
name: "unit_test; Dart beta; PKG: json_serializable; `pub run test -p chrome`"
326+
name: "unit_test; Dart 2.12.0; PKG: json_serializable; `pub run test -p chrome`"
327327
runs-on: ubuntu-latest
328328
steps:
329329
- name: Cache Pub hosted dependencies
330330
uses: actions/cache@v2
331331
with:
332332
path: "~/.pub-cache/hosted"
333-
key: "os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:json_serializable;commands:test_2"
333+
key: "os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:json_serializable;commands:test_2"
334334
restore-keys: |
335-
os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:json_serializable
336-
os:ubuntu-latest;pub-cache-hosted;dart:beta
335+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:json_serializable
336+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0
337337
os:ubuntu-latest;pub-cache-hosted
338338
os:ubuntu-latest
339-
- uses: dart-lang/setup-dart@v0.3
339+
- uses: dart-lang/setup-dart@v1.0
340340
with:
341-
sdk: beta
341+
sdk: "2.12.0"
342342
- id: checkout
343343
uses: actions/checkout@v2
344344
- id: json_serializable_pub_upgrade
@@ -368,7 +368,7 @@ jobs:
368368
os:ubuntu-latest;pub-cache-hosted;dart:dev
369369
os:ubuntu-latest;pub-cache-hosted
370370
os:ubuntu-latest
371-
- uses: dart-lang/setup-dart@v0.3
371+
- uses: dart-lang/setup-dart@v1.0
372372
with:
373373
sdk: dev
374374
- id: checkout
@@ -387,22 +387,22 @@ jobs:
387387
- job_002
388388
- job_003
389389
job_008:
390-
name: "ensure_build; Dart beta; PKGS: _test_yaml, checked_yaml, example, json_serializable; `pub run test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
390+
name: "ensure_build; Dart 2.12.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `pub run test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
391391
runs-on: ubuntu-latest
392392
steps:
393393
- name: Cache Pub hosted dependencies
394394
uses: actions/cache@v2
395395
with:
396396
path: "~/.pub-cache/hosted"
397-
key: "os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_1"
397+
key: "os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_1"
398398
restore-keys: |
399-
os:ubuntu-latest;pub-cache-hosted;dart:beta;packages:_test_yaml-checked_yaml-example-json_serializable
400-
os:ubuntu-latest;pub-cache-hosted;dart:beta
399+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0;packages:_test_yaml-checked_yaml-example-json_serializable
400+
os:ubuntu-latest;pub-cache-hosted;dart:2.12.0
401401
os:ubuntu-latest;pub-cache-hosted
402402
os:ubuntu-latest
403-
- uses: dart-lang/setup-dart@v0.3
403+
- uses: dart-lang/setup-dart@v1.0
404404
with:
405-
sdk: beta
405+
sdk: "2.12.0"
406406
- id: checkout
407407
uses: actions/checkout@v2
408408
- id: _test_yaml_pub_upgrade
@@ -463,7 +463,7 @@ jobs:
463463
os:ubuntu-latest;pub-cache-hosted;dart:dev
464464
os:ubuntu-latest;pub-cache-hosted
465465
os:ubuntu-latest
466-
- uses: dart-lang/setup-dart@v0.3
466+
- uses: dart-lang/setup-dart@v1.0
467467
with:
468468
sdk: dev
469469
- id: checkout

Diff for: _test_yaml/mono_pkg.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# See https://github.com/google/mono_repo.dart for details on this file
22
dart:
3-
- beta # change this to 1.12.0 when it's released!
3+
- 2.12.0
44
- dev
55

66
stages:

Diff for: _test_yaml/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: _test_yaml
22
publish_to: none
33

44
environment:
5-
sdk: '>=2.12.0-0 <3.0.0'
5+
sdk: '>=2.12.0 <3.0.0'
66

77
dev_dependencies:
88
build_runner: ^1.0.0

Diff for: _test_yaml/test/yaml_test.dart

-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ line 4, column 21 of file.yaml: Unsupported value for "configLocation". Illegal
160160
╵'''
161161
};
162162

163-
// ignore: deprecated_member_use
164-
final throwsCastError = throwsA(isA<CastError>());
165-
166163
T roundTripObject<T>(
167164
T object,
168165
T Function(Map<String, dynamic> json) factory, {

Diff for: analysis_options.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ linter:
88
- always_require_non_null_named_parameters
99
- annotate_overrides
1010
- avoid_catching_errors
11+
- avoid_dynamic_calls
1112
- avoid_empty_else
1213
- avoid_function_literals_in_foreach_calls
1314
- avoid_init_to_null
@@ -20,6 +21,7 @@ linter:
2021
- avoid_returning_null
2122
- avoid_returning_null_for_void
2223
- avoid_shadowing_type_parameters
24+
- avoid_single_cascade_in_expression_statements
2325
- avoid_types_as_parameter_names
2426
- avoid_unused_constructor_parameters
2527
- avoid_void_async
@@ -87,6 +89,7 @@ linter:
8789
- provide_deprecation_message
8890
- recursive_getters
8991
- slash_for_doc_comments
92+
- sort_child_properties_last
9093
- sort_pub_dependencies
9194
- test_types_in_equals
9295
- throw_in_finally
@@ -105,7 +108,10 @@ linter:
105108
- unnecessary_string_interpolations
106109
- unnecessary_this
107110
- unrelated_type_equality_checks
111+
- unsafe_html
112+
- use_full_hex_values_for_flutter_colors
108113
- use_function_type_syntax_for_parameters
114+
- use_is_even_rather_than_modulo
109115
- use_rethrow_when_possible
110116
- use_string_buffers
111117
- valid_regexps

Diff for: checked_yaml/CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
## 2.0.0-dev
1+
## 2.0.1
2+
3+
- If `CheckedFromJsonException` is caught for a key missing in the source map,
4+
include those details in the thrown `ParsedYamlException`.
5+
6+
- Correctly handle the case where `CheckedFromJsonException.message` is `null`.
7+
8+
## 2.0.0
29

310
- *BREAKING* `checkedYamlDecode` `sourceUrl` parameter is now a `Uri`.
411
- Require at least Dart `2.12.0-0`.

Diff for: checked_yaml/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ for the class annotation.
1818
class Configuration {
1919
@JsonKey(required: true)
2020
final String name;
21-
@JsonKey(required: true)
2221
final int count;
2322
2423
Configuration({required this.name, required this.count}) {

Diff for: checked_yaml/example/example.dart

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ part 'example.g.dart';
1717
class Configuration {
1818
@JsonKey(required: true)
1919
final String name;
20-
@JsonKey(required: true)
2120
final int count;
2221

2322
Configuration({required this.name, required this.count}) {

Diff for: checked_yaml/example/example.g.dart

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: checked_yaml/lib/checked_yaml.dart

+12-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,18 @@ ParsedYamlException toParsedYamlException(
7575
innerError: exception,
7676
);
7777
} else {
78-
final yamlValue = yamlMap.nodes[exception.key];
79-
80-
if (yamlValue == null) {
81-
// TODO: test this case!
78+
if (exception.key == null) {
79+
return ParsedYamlException(
80+
exception.message ?? 'There was an error parsing the map.',
81+
yamlMap,
82+
innerError: exception,
83+
);
84+
} else if (!yamlMap.containsKey(exception.key)) {
8285
return ParsedYamlException(
83-
exception.message!,
86+
[
87+
'Missing key "${exception.key}".',
88+
if (exception.message != null) exception.message!,
89+
].join(' '),
8490
yamlMap,
8591
innerError: exception,
8692
);
@@ -91,7 +97,7 @@ ParsedYamlException toParsedYamlException(
9197
}
9298
return ParsedYamlException(
9399
message,
94-
yamlValue,
100+
yamlMap.nodes[exception.key] ?? yamlMap,
95101
innerError: exception,
96102
);
97103
}

Diff for: checked_yaml/mono_pkg.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# See https://github.com/google/mono_repo.dart for details on this file
22
dart:
3-
- beta # change this to 1.12.0 when it's released!
3+
- 2.12.0
44
- dev
55

66
stages:

Diff for: checked_yaml/pubspec.yaml

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
name: checked_yaml
2-
version: 1.9.0-dev
2+
version: 2.0.1
33

44
description: >-
55
Generate more helpful exceptions when decoding YAML documents using
66
package:json_serializable and package:yaml.
7-
repository: https://github.com/google/json_serializable.dart
7+
repository: https://github.com/google/json_serializable.dart/tree/master/checked_yaml
88
environment:
9-
sdk: '>=2.12.0-0 <3.0.0'
9+
sdk: '>=2.12.0 <3.0.0'
1010

1111
dependencies:
12-
json_annotation: '>=2.2.0 <5.0.0'
12+
json_annotation: ^4.0.0
1313
source_span: ^1.8.0
1414
yaml: ^3.0.0
1515

1616
dev_dependencies:
1717
build_runner: ^1.0.0
1818
build_verify: ^1.1.0
19-
json_serializable: ^3.0.0
19+
json_serializable: ^4.0.0
2020
path: ^1.0.0
2121
test: ^1.16.0
22-
test_process: ^1.0.1
22+
test_process: ^2.0.0
2323

2424
dependency_overrides:
25-
json_annotation:
26-
path: ../json_annotation
27-
json_serializable:
28-
path: ../json_serializable
25+
# Need to update dependencies on these packages
26+
build_config: ^0.4.4
27+
pubspec_parse: ^0.1.5

Diff for: checked_yaml/test/custom_error_test.dart

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:checked_yaml/checked_yaml.dart';
2+
import 'package:json_annotation/json_annotation.dart';
3+
import 'package:test/test.dart';
4+
import 'package:yaml/yaml.dart';
5+
6+
void main() {
7+
test('bob', () {
8+
expect(
9+
() => checkedYamlDecode(
10+
'{"innerMap": {}}',
11+
(m) {
12+
throw CheckedFromJsonException(
13+
m!['innerMap'] as YamlMap,
14+
null,
15+
'nothing',
16+
null,
17+
);
18+
},
19+
),
20+
throwsA(
21+
isA<ParsedYamlException>()
22+
.having(
23+
(e) => e.message,
24+
'message',
25+
'There was an error parsing the map.',
26+
)
27+
.having((e) => e.yamlNode, 'yamlNode', isA<YamlMap>())
28+
.having(
29+
(e) => e.innerError,
30+
'innerError',
31+
isA<CheckedFromJsonException>(),
32+
)
33+
.having((e) => e.formattedMessage, 'formattedMessage', '''
34+
line 1, column 14: There was an error parsing the map.
35+
36+
1 │ {"innerMap": {}}
37+
│ ^^
38+
╵'''),
39+
),
40+
);
41+
});
42+
}

0 commit comments

Comments
 (0)