Skip to content

[tool] Add test_data directory to cognitive complexity check - #12523

Open
camsim99 wants to merge 3 commits into
flutter:mainfrom
camsim99:cogcomp_test_data
Open

[tool] Add test_data directory to cognitive complexity check#12523
camsim99 wants to merge 3 commits into
flutter:mainfrom
camsim99:cogcomp_test_data

Conversation

@camsim99

Copy link
Copy Markdown
Contributor

camera_android_camerax uses test_data directories for scripts used in evals for skills. Let's include those scripts in the cognitive complexity check. Follow up from #12369 (comment)

Pre-Review Checklist

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

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

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 20, 2026

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

Copy link
Copy Markdown
Contributor

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 expands the cognitive_complexity analysis to include Dart files within evals/test_data and specific .agents/skills/ subdirectories, rather than limiting it to the lib/ directory. Feedback suggests optimizing performance by only recursively scanning the specific target directories instead of listing the entire package directory, which can contain large build artifacts.

Comment on lines 375 to 388
final filesToAnalyze = <String>[];
for (final FileSystemEntity entity in package.libDirectory.listSync(recursive: true)) {
for (final FileSystemEntity entity in package.directory.listSync(recursive: true)) {
if (entity is File && entity.path.endsWith('.dart') && !_isGeneratedDartFile(entity.path)) {
final String relativePath = path.relative(entity.path, from: package.directory.path);
filesToAnalyze.add(relativePath.replaceAll(r'\', '/'));
final String posixPath = relativePath.replaceAll(r'\', '/');
final bool isLib = posixPath.startsWith('lib/');
final bool isRootEvalData = posixPath.startsWith('evals/test_data/');
final bool isSkillEvalData =
posixPath.startsWith('.agents/skills/') && posixPath.contains('/evals/test_data/');
if (isLib || isRootEvalData || isSkillEvalData) {
filesToAnalyze.add(posixPath);
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Listing the entire package directory recursively (package.directory.listSync(recursive: true)) is highly inefficient and can cause significant performance bottlenecks in CI/CD pipelines, especially for large packages with many build artifacts (e.g., .dart_tool/, build/, ios/Pods/, node_modules/).

Since we only care about Dart files in lib/, evals/test_data/, and .agents/skills/, we should only recursively list those specific directories if they exist.

    final List<Directory> directoriesToSearch = <Directory>[
      package.libDirectory,
      package.directory.childDirectory('evals').childDirectory('test_data'),
      package.directory.childDirectory('.agents').childDirectory('skills'),
    ];
    final List<String> filesToAnalyze = <String>[];
    for (final Directory dir in directoriesToSearch) {
      if (!dir.existsSync()) {
        continue;
      }
      for (final FileSystemEntity entity in dir.listSync(recursive: true)) {
        if (entity is File && entity.path.endsWith('.dart') && !_isGeneratedDartFile(entity.path)) {
          final String relativePath = path.relative(entity.path, from: package.directory.path);
          final String posixPath = relativePath.replaceAll(r'\', '/');
          final bool isLib = posixPath.startsWith('lib/');
          final bool isRootEvalData = posixPath.startsWith('evals/test_data/');
          final bool isSkillEvalData = 
              posixPath.startsWith('.agents/skills/') && posixPath.contains('/evals/test_data/');
          if (isLib || isRootEvalData || isSkillEvalData) {
            filesToAnalyze.add(posixPath);
          }
        }
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant