Coder Social home page Coder Social logo

dart-common-toolkit / dart-enum-to-string-check Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 66 KB

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

License: MIT License

Dart 100.00%
dart-analyzer dart-analysis dart-analysis-server flutter-analyze

dart-enum-to-string-check's Introduction

ATTENTION

Because last Dart version supports name parameter this plugin is recommended to use on old Dart revisions. Right now repository is not in Archive because plugin have some bugs that can be fixed in future. After all checks and fully compatible understanding, repository can be placed to Archive.

dart_enum_to_string_check

GitHubActions Coverage pub.dev

About

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

Motivation

Default enum.toString() method represents an enum constant as class name + constant name (for example, when we call color.toString() we have Colors.green but not green). In some cases this cast is not valid for an app 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 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: ^0.8.3

Add plugin 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:

$ dart pub global activate dart_enum_to_string_check

Then run from project folder:

$ 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

dart-enum-to-string-check's People

Contributors

fartem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hdw09 fartem

dart-enum-to-string-check's Issues

Add Dart 2.13 support

Right now plugin cannot run as a Dart Analyzer plugin and from CLI. This issue starts from version 0.7.3 of this plugin (Dart 2.12). Also, issues might be by new Dart version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.