-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[flutter_plugin_tools] Add a command to lint Android code #4206
Conversation
This is a WIP since the new command will fail on many plugins. @blasten How do you want to proceed here:
My preference is (1) since it uses the established place for tracking what's currently not turned on, but I can see a good argument for (2) as well given that we'd have output on the bots to work from right away. (We'll need an issues tracking getting it fully running for whatever option we choose, of course.) Other open questions:
|
|
||
// TODO(stuartmorgan): Consider adding an XML parser to read and summarize | ||
// all results. Currently, only the first three errors will be shown, and | ||
// the rest are only in an XML file that won't be accessible for CI runs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If moved to Github Actions, it could upload the generated HTML as an attachment using the GitHub API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Cirrus could do it too: https://cirrus-ci.org/guide/writing-tasks/#artifacts-instruction. In fact: https://cirrus-ci.org/examples/#android-lint looks pretty interesting.
I can see how easy it will be to manage storage; we'd want them to auto-expire, ideally.
|
||
@override | ||
final String description = 'Runs "gradlew lint" on Android plugins.\n\n' | ||
'Requires the example to have been build at least once before running.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it only requires flutter pub get
. Could this command invoke it before running ./gradlew?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not appear to be the case. Maybe flutter
should have a specific command to generate files like this without actually doing builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you remember what file was missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, gradlew
.
If you git clean
a Flutter app (which removes android/gradlew
), then flutter pub get
or flutter packages get
there's still no android/gradlew
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the minor comments
Ideally, plugins don't use baseline files since these are meant to hide existing issues.
For the time being, could it dump the xml content to stdout? |
Sorry, by baseline options I meant "are there any non-default lint settings we want to set". E.g., I don't know if there are things that aren't checked by default but we would want to enable. But looking at baseline files more now that I know of them, that's strictly better than
I'll see how the parsed-by-Cirrus options pans out, and fall back to this if it doesn't give us what we need. Hopefully I'll have a new version of the PR up later today. |
@blasten Okay, I think this is ready for a full review now. Changes:
|
Sounds good what is the awesome integration that shows linter warnings as GitHub comments in the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This is great!
Adds a new `lint-android` command to run `gradlew lint` on Android plugins. Also standardizes the names of the Cirrus tasks that run all the build and platform-specific (i.e., not Dart unit test) tests for each platform, as they were getting unnecessarily long and complex in some cases. Fixes flutter/flutter#87071
Adds a new `lint-android` command to run `gradlew lint` on Android plugins. Also standardizes the names of the Cirrus tasks that run all the build and platform-specific (i.e., not Dart unit test) tests for each platform, as they were getting unnecessarily long and complex in some cases. Fixes flutter/flutter#87071
Adds a new
lint-android
command to rungradlew lint
on Android plugins.Also standardizes the names of the Cirrus tasks that run all the build and platform-specific (i.e., not Dart unit test) tests for each platform, as they were getting unnecessarily long and complex in some cases.
Fixes flutter/flutter#87071
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).