Skip to content

Commit a4edc02

Browse files
Update README.md (#1475)
This seems to be a common question that is quite difficult to answer. The most visible solution I found previously was to use the `remove_from_coverage` package to remove generated files from the coverage report. That solution complicates CLI commands and requires updating CI/CD pipelines.
1 parent 5716df7 commit a4edc02

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

json_serializable/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,18 @@ targets:
287287
include_if_null: true
288288
```
289289

290+
To exclude generated files from coverage, you can further configure `build.yaml`.
291+
292+
```yaml
293+
targets:
294+
$default:
295+
builders:
296+
source_gen:combining_builder:
297+
options:
298+
preamble: |
299+
// coverage:ignore-file
300+
```
301+
290302
[example]: https://github.com/google/json_serializable.dart/tree/master/example
291303
[dart build system]: https://github.com/dart-lang/build
292304
[package:json_annotation]: https://pub.dev/packages/json_annotation

json_serializable/tool/readme/readme_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ targets:
152152
include_if_null: true
153153
```
154154
155+
To exclude generated files from coverage, you can further configure `build.yaml`.
156+
157+
```yaml
158+
targets:
159+
$default:
160+
builders:
161+
source_gen:combining_builder:
162+
options:
163+
preamble: |
164+
// coverage:ignore-file
165+
```
166+
155167
[example]: https://github.com/google/json_serializable.dart/tree/master/example
156168
[dart build system]: https://github.com/dart-lang/build
157169
[package:json_annotation]: https://pub.dev/packages/json_annotation

0 commit comments

Comments
 (0)