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

outdated

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

dart_enum_to_string_check #

GitHubActions

About #

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

Motivation #

Default Enum.toString() method represent enum constant as class name and 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 can causing problems (when from DB you get strings without class names, "green" == Colors.green.toString() is not as we need). 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:
    git:
      url: https://github.com/fartem/dart-enum-to-string-check.git
      ref: master

Add plugin name to analysis_options.yaml:

analyzer:
  plugins:
    - dart_enum_to_string_check

Then restart Dart Analyzer Server.

From CLI #

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
0
points
62
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, analyzer_plugin, glob, path, yaml

More

Packages that depend on dart_enum_to_string_check