Skip to content

Commit b2cc192

Browse files
authored
Add Gemini Code Assist review config and style guide (flutter#172785)
- Initial config files for [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). These config files are modified versions of the one already added to the flutter/packages repo: flutter/packages#9632 based on [the official docs](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). - Style guide has links to various contributing docs and style guides. - Ignore paths associated with version pins and third_party to avoid reviews on rolls and code that doesn't need modification. See flutter/packages#9647. - Add a note to the PR template to provide some notice/guidance to contributors about how to use automated feedback, to clarify the role of the automated reviews and hopefully minimize potential issues in case the bot leaves incorrect feedback. This is a direct copy of the comment introduced in flutter/packages#9632. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 053c8a5 commit b2cc192

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

.gemini/config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimize verbosity.
2+
have_fun: false
3+
code_review:
4+
# For now, use the default of MEDIUM for testing. Based on desired verbosity,
5+
# we can change this to LOW or HIGH in the future.
6+
comment_severity_threshold: MEDIUM
7+
pull_request_opened:
8+
# Explicitly set help to false in case the default changes in the future, as
9+
# having a help message on every PR would be spammy.
10+
help: false
11+
# These tend to be verbose, and since we expect PR authors to clearly
12+
# describe their PRs this would be at best duplicative.
13+
summary: false
14+
ignore_patterns:
15+
# Avoid code reviews on rolls.
16+
- DEPS
17+
- bin/internal/*.version
18+
- engine/src/flutter/ci/licenses_golden/**
19+
# Avoid code reviews on all third_party files.
20+
- **/third_party/**

.gemini/styleguide.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Flutter Style Guide
2+
3+
This style guide outlines the coding conventions for contributions to the
4+
flutter/flutter repository. It is based on the more comprehensive official
5+
[style guide for the Flutter repository](https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md).
6+
7+
## Best Practices
8+
- Code should follow the guidance and principles described in
9+
[the Flutter contribution guide](https://github.com/flutter/flutter/blob/main/CONTRIBUTING.md).
10+
- Code should be tested and follow the guidance described in the [writing effective tests guide](https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Writing-Effective-Tests.md) and the [running and writing tests guide](https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Running-and-writing-tests.md).
11+
- Changes to the [engine/ directory](https://github.com/flutter/flutter/tree/main/engine) should additionally have appropriate tests as described in [the engine test guidance](https://github.com/flutter/flutter/blob/main/engine/src/flutter/docs/testing/Testing-the-engine.md).
12+
- PR descriptions should include the Pre-launch Checklist from
13+
[the PR template](https://github.com/flutter/flutter/blob/main/.github/PULL_REQUEST_TEMPLATE.md),
14+
with all of the steps completed.
15+
16+
## General Philosophy
17+
18+
- **Optimize for readability**: Code is read more often than it is written.
19+
- **Avoid duplicating state**: Keep only one source of truth.
20+
- Write what you need and no more, but when you write it, do it right.
21+
- **Error messages should be useful**: Every error message is an opportunity to make someone love our product.
22+
23+
## Dart Formatting
24+
25+
- All Dart code is formatted using `dart format`. This is enforced by CI.
26+
- Constructors come first in a class definition, with the default constructor preceding named constructors.
27+
- Other class members should be ordered logically (e.g., by lifecycle, or grouping related fields and methods).
28+
29+
## Miscellaneous Languages
30+
31+
- Python code is formatted using `yapf`, linted with `pylint`, and should follow the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html).
32+
- C++ code is formatted using `clang-format`, linted with `clang-tidy`, and should follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
33+
- Shaders are formatted using `clang-format`.
34+
- Kotlin code is formatted using `ktformat`, linted with `ktlint`, and should follow the [Android Kotlin Style Guide](https://developer.android.com/kotlin/style-guide).
35+
- Java code is formatted using `google-java-format` and should follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
36+
- Objective-C is formatted using `clang-format`, linted with `clang-tidy`, and should follow the [Google Objective-C Style Guide](https://google.github.io/styleguide/objcguide.html).
37+
- Swift is formatted and linted using `swift-format` and should follow the [Google Swift Style Guide](https://google.github.io/swift).
38+
- GN code is formatted using `gn format` and should follow the [GN Style Guide](https://gn.googlesource.com/gn/+/main/docs/style_guide.md).
39+
40+
## Documentation
41+
42+
- All public members should have documentation.
43+
- **Answer your own questions**: If you have a question, find the answer, and then document it where you first looked.
44+
- **Avoid useless documentation**: If the documentation just repeats the member's name, it's useless. Explain the *why* and the *how*.
45+
- **Introduce terms**: Don't assume the reader knows everything. Link to definitions.
46+
- **Provide sample code**: Use `{@tool dartpad}` for runnable examples.
47+
- **Provide illustrations or screenshots** for widgets.
48+
- Use `///` for public-quality documentation, even on private members.
49+
50+
## Further Reading
51+
52+
For more detailed guidance, refer to the following documents:
53+
54+
- [Style guide for the Flutter repository](https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md)
55+
- [Effective Dart: Style](https://dart.dev/effective-dart/style)
56+
- [Tree Hygiene](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md)
57+
- [The Flutter contribution guide](https://github.com/flutter/flutter/blob/main/CONTRIBUTING.md)
58+
- [Writing effective tests guide](https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Writing-Effective-Tests.md)
59+
- [Running and writing tests guide](https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Running-and-writing-tests.md)
60+
- [Engine testing guide](https://github.com/flutter/flutter/blob/main/engine/src/flutter/docs/testing/Testing-the-engine.md)

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ To learn more about code review, see our documentation on Tree Hygiene: https://
2424

2525
If you need help, consider asking for advice on the #hackers-new channel on [Discord].
2626

27+
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
28+
2729
<!-- Links -->
2830
[Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
2931
[Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md

0 commit comments

Comments
 (0)