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.

@@ -35,482 +36,551 @@ void main() {
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.

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

Successfully merging this pull request may close these issues.

2 participants