Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run rustfmt on generated rust code #500

Open
2bndy5 opened this issue Jan 23, 2025 · 2 comments
Open

run rustfmt on generated rust code #500

2bndy5 opened this issue Jan 23, 2025 · 2 comments

Comments

@2bndy5
Copy link
Contributor

2bndy5 commented Jan 23, 2025

I'm setting up some CI for my app, and cargo fmt --check fails on numerous files found in native/hub/src/messages/.

Unfortunately, rustfmt's ignore option is unstable and requires nightly toolchain(s).

I was wondering if running rustfmt on just the hub package is feasible in flutter_package/bin/src/message.dart

cargo fmt -p hub

Perhaps this could be an opt-in feature using a CLI option. Because there's no guarantee that user code in the hub package (outside the messages module) would be compilable.


This part is a little off topic. I guess something similar could be considered for flutter analyze. Maybe some API from the dart SDK could be used instead of spinning up a shell to run flutter analyze. Fortunately, users can exclude paths using analyzer config options.

@temeddix
Copy link
Member

I think we can apply cargo fmt every time after message generation, if we can only target the messages folder in Dart and Rust. We are open for any PR for that.

Let me share that I'm busy at the moment, and cannot really write code for that. However, if there is any PR for that, I'd be happy to review and merge it into the main branch, also publishing a new Rinf version.

Thank you for your participation :)

@2bndy5
Copy link
Contributor Author

2bndy5 commented Jan 24, 2025

I think we can apply cargo fmt every time after message generation, if we can only target the messages folder

Good idea. I didn't realize we could explicitly pass file paths to rustfmt

rustfmt native/hub/src/messages/mod.rs ...

This approach would be most non-intrusive! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@2bndy5 @temeddix and others