Skip to content

[packages] [tool] Refactor Gradle lint analysis to aggregate errors across examples #188867

Description

@reidbaker-agent

In script/tool/lib/src/analyze_command.dart, the method _runGradleLintForPackage runs Gradle lint analysis on the examples of a package.

Currently, it loops over the examples and fails early (returning PackageResult.fail() immediately) if configuration or linting fails for any single example:

    for (final RepositoryPackage example in package.getExamples()) {
      final project = GradleProject(example, processRunner: processRunner, platform: platform);

      if (!project.isConfigured()) {
        final bool buildSuccess = await runConfigOnlyBuild(
          example,
          processRunner,
          platform,
          FlutterPlatform.android,
        );
        if (!buildSuccess) {
          printError('Unable to configure Gradle project.');
          return PackageResult.fail(<String>['Unable to configure Gradle.']);
        }
      }
      
      ...
      
      final int exitCode = await project.runCommand('$packageName:lintDebug');
      if (exitCode != 0) {
        return PackageResult.fail();
      }
    }

This is an anti-pattern for repository tooling because it prevents the developer from seeing lint failures from other examples in the same run.

Instead, it should follow the design pattern used by _runXcodeAnalysisForPackage in the same class:

  1. Initialize a local errors list.
  2. Accumulate configuration or linting errors inside the loop.
  3. Return errors.isEmpty ? PackageResult.success() : PackageResult.fail(errors) at the end of the loop.

This will improve developer velocity by providing comprehensive feedback in a single CI or local analysis run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions