From cbb676a2b2d631a53ff96768d915bc5736b416d5 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Wed, 14 Feb 2024 10:11:23 -0800 Subject: [PATCH] [tools] Ignore analysis options files in .symlinks (#6119) When running `analyze` in a local tree that has done builds, there can be false positives of the "unexpected analysis options" check due to the .symlinks directory making other packages' analysis options show up in the check. This avoids following links to prevent those false positives. --- script/tool/lib/src/analyze_command.dart | 2 +- script/tool/test/analyze_command_test.dart | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/script/tool/lib/src/analyze_command.dart b/script/tool/lib/src/analyze_command.dart index 15a8ef2e12..2f7d28217a 100644 --- a/script/tool/lib/src/analyze_command.dart +++ b/script/tool/lib/src/analyze_command.dart @@ -66,7 +66,7 @@ class AnalyzeCommand extends PackageLoopingCommand { /// Checks that there are no unexpected analysis_options.yaml files. bool _hasUnexpecetdAnalysisOptions(RepositoryPackage package) { final List files = - package.directory.listSync(recursive: true); + package.directory.listSync(recursive: true, followLinks: false); for (final FileSystemEntity file in files) { if (file.basename != 'analysis_options.yaml' && file.basename != '.analysis_options') { diff --git a/script/tool/test/analyze_command_test.dart b/script/tool/test/analyze_command_test.dart index 15da8db22c..27e92dd5e0 100644 --- a/script/tool/test/analyze_command_test.dart +++ b/script/tool/test/analyze_command_test.dart @@ -273,6 +273,23 @@ void main() { ])); }); + test('ignores analysis options in the plugin .symlinks directory', + () async { + final RepositoryPackage plugin = createFakePlugin('foo', packagesDir, + extraFiles: ['analysis_options.yaml']); + final RepositoryPackage includingPackage = + createFakePlugin('bar', packagesDir); + // Simulate the local state of having built 'bar' if it includes 'foo'. + includingPackage.directory + .childDirectory('example') + .childDirectory('ios') + .childLink('.symlinks') + .createSync(plugin.directory.path, recursive: true); + + await runCapturingPrint( + runner, ['analyze', '--custom-analysis', 'foo']); + }); + test('takes an allow config file', () async { final RepositoryPackage plugin = createFakePlugin('foo', packagesDir, extraFiles: ['analysis_options.yaml']);