flutter_rust_bridge icon indicating copy to clipboard operation
flutter_rust_bridge copied to clipboard

✨ Adds `dart fix` when generating files

Open AlexV525 opened this issue 1 year ago • 9 comments

Changes

Please list issues fixed by this PR here, using format "Fixes #the-issue-number".

Checklist

  • [ ] An issue to be fixed by this PR is listed above.
  • [ ] New tests are added to ensure new features are working. Please refer to this page to see how to add a test.
  • [ ] ./frb_internal precommit --mode slow (or fast) is run (it internal runs code generator, does auto formatting, etc).
  • [ ] If this PR adds/changes features, documentations (in the ./website folder) are updated.
  • [ ] CI is passing. Please refer to this page to see how to solve a failed CI.

AlexV525 avatar Jul 03 '24 09:07 AlexV525

Hi! Thanks for opening this pull request! :smile:

welcome[bot] avatar Jul 03 '24 09:07 welcome[bot]

Good idea! I wonder how long does it take (will it be very slow or not), and may I know what it fixes for your scenario?

fzyzcjy avatar Jul 03 '24 10:07 fzyzcjy

Good idea! I wonder how long does it take (will it be very slow or not)

Probably 2~3x compared to dart format.

and may I know what it fixes for your scenario?

Yeah I'm grabbing some summary then I'll put it in the top comment. In general, people apply different lint rules in their libraries so this will help the generated files follow their rules. Also fix then format could help to solve most of the lints.

AlexV525 avatar Jul 03 '24 10:07 AlexV525

I see. Btw, there may be another way as well: what about using // ignore_for_file: whatever_rule_name_here for the default rules, and also dart_preamble: ... for extra custom rules?

EDIT: If we want to ensure we ignore as many things as possible, we may also enable all linter rules in our frb_example/pure_dart test, then we will know what rules to ignore

fzyzcjy avatar Jul 03 '24 10:07 fzyzcjy

Do we have tests against the generated files? Like testing the dart format woks properly.

AlexV525 avatar Jul 15 '24 03:07 AlexV525

Codecov Report

Attention: Patch coverage is 97.14286% with 2 lines in your changes missing coverage. Please review.

Project coverage is 99.06%. Comparing base (a44f789) to head (46e7100). Report is 45 commits behind head on master.

Files Patch % Lines
frb_codegen/src/library/commands/dart_fix.rs 96.22% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2182      +/-   ##
==========================================
- Coverage   99.07%   99.06%   -0.01%     
==========================================
  Files         487      488       +1     
  Lines       20160    20197      +37     
==========================================
+ Hits        19974    20009      +35     
- Misses        186      188       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 15 '24 03:07 codecov[bot]

Do we have tests against the generated files? Like testing the dart format woks properly.

Check .github/workflows/ci.yaml, iirc the CI / Ling :: Dart :: Primary will check every repo's formatting, including the generated ones.

fzyzcjy avatar Jul 15 '24 04:07 fzyzcjy

How is this going on now? I also realize that some of the generated dart files would be changed slightly after running dart fix , like this:

PS D:\DATA\BaiduSyncdisk\project\personal\proxy> dart fix --apply
Computing fixes in proxy...
Applying fixes...

lib\rust\frb_generated.dart
  avoid_return_types_on_setters • 7 fixes

lib\rust\proxy\node.dart
  annotate_overrides • 1 fix

lib\rust\proxy\node\trojan.dart
  annotate_overrides • 7 fixes

lib\rust\proxy\node\vless.dart
  annotate_overrides • 1 fix

lib\rust\proxy\node\vmess.dart
  annotate_overrides • 1 fix

the main change is trivial like this: image

dbsxdbsx avatar Aug 03 '24 01:08 dbsxdbsx

I didn't find spare time to update this in recent weeks, but the feature is working on this branch. You can cherry-pick these commits to your fork and manually installs it.

AlexV525 avatar Aug 03 '24 01:08 AlexV525

https://github.com/fzyzcjy/flutter_rust_bridge/actions/runs/10748747038/job/29812854778?pr=2182

image

AlexV525 avatar Sep 07 '24 07:09 AlexV525

Hmm maybe just rerun it... Sometimes I do see weird flakiness

EDIT: I have triggered rerun

fzyzcjy avatar Sep 07 '24 08:09 fzyzcjy

Could you also retrigger the codecov workflow? It seems to be throttled 😂 https://github.com/fzyzcjy/flutter_rust_bridge/actions/runs/10748747038/job/29815531574?pr=2182

AlexV525 avatar Sep 07 '24 08:09 AlexV525

Sure, done

fzyzcjy avatar Sep 07 '24 10:09 fzyzcjy

Hmm still throttled. Anything that might help with it?

AlexV525 avatar Sep 07 '24 12:09 AlexV525

I seemed to have seen this throttling for several times... Have not searched deeply about it. Maybe you can firstly finish the pr and ready for review, and we can consider codecov before really merging.

fzyzcjy avatar Sep 07 '24 15:09 fzyzcjy

Okay so the PR should be good for review then.

AlexV525 avatar Sep 07 '24 16:09 AlexV525

Great! I will review probably within a day

fzyzcjy avatar Sep 08 '24 00:09 fzyzcjy

@all-contributors please add @AlexV525 for code

fzyzcjy avatar Sep 08 '24 07:09 fzyzcjy

@fzyzcjy

I've put up a pull request to add @AlexV525! :tada:

allcontributors[bot] avatar Sep 08 '24 07:09 allcontributors[bot]

Looks great!

fzyzcjy avatar Sep 09 '24 06:09 fzyzcjy

Hi! Congrats on merging your first pull request! :tada:

welcome[bot] avatar Sep 09 '24 06:09 welcome[bot]