null_safety_percentage 1.0.0 copy "null_safety_percentage: ^1.0.0" to clipboard
null_safety_percentage: ^1.0.0 copied to clipboard

outdated

Command-line tool to provide null-safety percentage info of a project. Track your migration progress on mixed-version programs that execute with unsound null safety.

null_safety_percentage #

Command-line tool to provide null-safety percentage info of a project. Track your migration progress on mixed-version programs that execute with unsound null safety.

Continuous Integration codecov null_safety_percentage Published by dartside.dev GitHub Stars Count

Motivation #

A Dart program can contain some libraries that are null safe and some that aren’t. These mixed-version programs execute with unsound null safety. - Dart: Unsound null safety

For smaller projects, migrating to null safety can be done in a matter of minutes. Unfortunately, if you are not satisfied with the automatically migrated code and you want to do the migration on your own, the migration of large code-bases can take a while.

This command-line tool lets you track your progress of your null-safety migration

It supports multiple output formats, so for example if you want to add a check in your CI/CD tool to ensure that your "null-safety coverage percentage"

Usage #

Install the null_safety_percentage command-line tool either globally or as a dev dependency.

null_safety_percentage command-line tool #

Keep in mind that how you invoke the null_safety_percentage depends on how you installed it and whether you are using it from a Flutter or Dart project.

Global installation

If you install null_safety_percentage globally, you can execute it simply by typing null_safety_percentage lib test.

dart pub global activate null_safety_percentage # or: flutter pub global activate null_safety_percentage

null_safety_percentage --help
null_safety_percentage --version

null_safety_percentage lib
null_safety_percentage lib test
null_safety_percentage --output-format json lib test
null_safety_percentage --output-format=json lib test
null_safety_percentage --output-format human --verbose lib

As dev dependency

You can run Dart scripts from your dependencies using the dart run or flutter run command.

  1. Add null_safety_percentage to your dev_dependencies: dart pub add -d null_safety_percentage or flutter pub add -d null_safety_percentage.
  2. Run the script dart run null_safety_percentage lib test or flutter run null_safety_percentage lib test. See more example scripts above.

Caveats #

The tool is in its early phases and is written so that it runs correctly on the projects I am working on.

Currently, the way the tool decides whether a file counts as migrated or not is pretty rudimentary. I assume there must be better ways to get this information, but this approach worked well enough for me. Improvements, recommendations are welcome.

The tool is not going to work on totally unmigrated libraries. I didn't want to add safe-guards against that, so please make sure that the "input" project is at least partially migrated.

example #

Don't forget the project's example folder for a project where you can test the command-line tool.

3
likes
0
pub points
43%
popularity

Publisher

verified publisherdartside.dev

Command-line tool to provide null-safety percentage info of a project. Track your migration progress on mixed-version programs that execute with unsound null safety.

Repository
View/report issues

License

unknown (LICENSE)

Dependencies

args

More

Packages that depend on null_safety_percentage