Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

Folds native code analysis commands into analyze to simplify the set of commands:

  • lint-android is now analyze --no-dart --android
  • xcode-analyze --ios is now analyze --no-dart --ios
  • xcode-analyze --macos is now analyze --no-dart --macos

In practice --no-dart is mostly there for CI; Dart analysis is fast enough that for local plugin development the new expected use case would likely be analyze --whateverplatorm, and it will run analysis on all relevant code in the package.

Part of flutter/flutter#173413

Pre-Review Checklist

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. 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.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the code analysis tooling by consolidating the lint-android and xcode-analyze commands into a single, more flexible analyze command. This new command allows running Dart and native code analysis for various platforms (Android, iOS, macOS) together or separately, controlled by flags. The changes include updating the AnalyzeCommand to handle different analysis types, removing the old command files, and updating CI configurations and documentation to use the new command. The test suite has also been significantly updated to cover the new unified command's functionality. My review found one critical issue in the CI configuration that needs to be addressed.


/// Runs Gradle lint analysis for the given package, and returns the result
/// that applies to that analysis.
Future<PackageResult> _runGradleLintForPackage(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is runForPackage from lint_android_command.dart, with essentially no changes beyond renaming.

}

/// Analyzes [plugin] for [targetPlatform].
Future<PackageResult> _runXcodeAnalysisForPackage(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is runForPackage from xcode_analyze_command.dart with some minor changes to make it return a PackageResult, and to include the skip logic that was a level higher in the old command. The result aggregation logic that xcode-analyze had is gone since analyze now has more generic aggregation logic that makes it unnecessary.

final RepositoryPackage plugin1 = createFakePlugin('a', packagesDir);

await runCapturingPrint(runner, <String>['analyze']);
group('result aggregation', () {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This small test group is new.

runner.addCommand(analyzeCommand);
});

test('analyzes all packages', () async {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the "removed" code is actually just wrapped in a new 'dart analyze' group.


test('skips commands if all files should be ignored', () async {
createFakePackage('package_a', packagesDir);
group('gradle lint', () {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This group is the old lint-android tests, with minor string changes where I changed some logging messages.

});

// TODO(stuartmorgan): Separate iOS and macOS.
group('Xcode analyze', () {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the old xcode-analyze tests with very minor tweaks.

@josemanuelcard

This comment was marked as spam.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 2, 2025
@auto-submit auto-submit bot merged commit 5d785a0 into flutter:main Sep 2, 2025
80 checks passed
@stuartmorgan-g stuartmorgan-g deleted the tool-analyze-combine branch September 2, 2025 17:11
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 2, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Sep 2, 2025
flutter/packages@3db5adc...5d785a0

2025-09-02 stuartmorgan@google.com [tool] Combine code analysis commands
into `analyze` (flutter/packages#9860)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
…#174840)

flutter/packages@3db5adc...5d785a0

2025-09-02 stuartmorgan@google.com [tool] Combine code analysis commands
into `analyze` (flutter/packages#9860)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
…#174840)

flutter/packages@3db5adc...5d785a0

2025-09-02 stuartmorgan@google.com [tool] Combine code analysis commands
into `analyze` (flutter/packages#9860)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants