Skip to content

Commit cbb676a

Browse files
[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.
1 parent de9654f commit cbb676a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

script/tool/lib/src/analyze_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class AnalyzeCommand extends PackageLoopingCommand {
6666
/// Checks that there are no unexpected analysis_options.yaml files.
6767
bool _hasUnexpecetdAnalysisOptions(RepositoryPackage package) {
6868
final List<FileSystemEntity> files =
69-
package.directory.listSync(recursive: true);
69+
package.directory.listSync(recursive: true, followLinks: false);
7070
for (final FileSystemEntity file in files) {
7171
if (file.basename != 'analysis_options.yaml' &&
7272
file.basename != '.analysis_options') {

script/tool/test/analyze_command_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,23 @@ void main() {
273273
]));
274274
});
275275

276+
test('ignores analysis options in the plugin .symlinks directory',
277+
() async {
278+
final RepositoryPackage plugin = createFakePlugin('foo', packagesDir,
279+
extraFiles: <String>['analysis_options.yaml']);
280+
final RepositoryPackage includingPackage =
281+
createFakePlugin('bar', packagesDir);
282+
// Simulate the local state of having built 'bar' if it includes 'foo'.
283+
includingPackage.directory
284+
.childDirectory('example')
285+
.childDirectory('ios')
286+
.childLink('.symlinks')
287+
.createSync(plugin.directory.path, recursive: true);
288+
289+
await runCapturingPrint(
290+
runner, <String>['analyze', '--custom-analysis', 'foo']);
291+
});
292+
276293
test('takes an allow config file', () async {
277294
final RepositoryPackage plugin = createFakePlugin('foo', packagesDir,
278295
extraFiles: <String>['analysis_options.yaml']);

0 commit comments

Comments
 (0)