dart_enum_to_string_check 0.8.3 copy "dart_enum_to_string_check: ^0.8.3" to clipboard
dart_enum_to_string_check: ^0.8.3 copied to clipboard

A plugin for Dart Analyzer for checking enum.toString() usages.

ATTENTION #

dart_enum_to_string_check #

GitHubActions Coverage pub.dev

About #

Plugin for Dart Analyzer to checking enum.toString() usages.

Motivation #

Default Enum.toString() method represents an enum constant as class name + constant name (example: Colors.green but not green). In some cases this cast is not valid for a program logic (parse values to DB or JSON and vice versa) and can causing some problems (when from DB you get a strings without class names, "green" == Colors.green.toString() is not as we needed). Plugin helps to prevent described problem.

How to use #

From Dart Analyzer Server #

Add plugin as development dependency in pubspec.yml:

dev_dependencies:

  dart_enum_to_string_check: ^0.8.3

Add plugin name to analysis_options.yaml:

analyzer:
  plugins:
    - dart_enum_to_string_check

Then restart Dart Analyzer Server.

From CLI #

With pub

To get dart_enum_to_string_check from pub, run from the shell:

Dart

pub global activate dart_enum_to_string_check

Flutter

flutter pub global activate dart_enum_to_string_check

Then run from project folder:

Dart

dart_enum_to_string_check

Flutter

flutter pub global run dart_enum_to_string_check

Without pub

Download plugin to your machine and provide bin/ location to PATH. Then run from project folder:

dart dart_enum_to_string_check.dart

References #

Solutions from dart-code-metrics by Wrike:

How to contribute #

Read Commit Convention. Make sure your build is green before you contribute your pull request. Then:

$ dart analyze
$ dart test

If you don't see any error messages, submit your pull request.

Contributors #

0
likes
120
pub points
12%
popularity

Publisher

unverified uploader

A plugin for Dart Analyzer for checking enum.toString() usages.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

analyzer, analyzer_plugin, file, glob, path, yaml

More

Packages that depend on dart_enum_to_string_check