diff --git a/CHANGELOG.md b/CHANGELOG.md index a8751c3e82..3f766af470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * test: added test case in [`prefer-const-border-radius`](https://dartcodemetrics.dev/docs/rules/flutter/prefer-const-border-radius) rule. * chore: restrict `analyzer` version to `>=2.4.0 <4.2.0`. +* fix: normalize file paths after extraction from analyzed folder. * fix: improve context root included files calculation. * fix: resolve package with imported analysis options. diff --git a/lib/src/utils/file_utils.dart b/lib/src/utils/file_utils.dart index 2109dab09c..7b99937fdc 100644 --- a/lib/src/utils/file_utils.dart +++ b/lib/src/utils/file_utils.dart @@ -23,5 +23,5 @@ Set extractDartFilesFromFolders( relative(entity.path, from: rootFolder), globalExcludes, )) - .map((entity) => entity.path)) + .map((entity) => normalize(entity.path))) .toSet(); diff --git a/test/src/utils/analyzer_utils_test.dart b/test/src/utils/analyzer_utils_test.dart index 3b1eb7fc71..1e82788124 100644 --- a/test/src/utils/analyzer_utils_test.dart +++ b/test/src/utils/analyzer_utils_test.dart @@ -73,5 +73,24 @@ void main() { }, testOn: 'posix', ); + + test( + 'should normalize file path if root path has relative parts', + () { + const rootFolder = 'test/resources/./'; + final excludes = [Glob('**/first*file.dart')]; + + final filePaths = + getFilePaths([folderPath], context, rootFolder, excludes).toList() + ..sort(); + + expect(filePaths, hasLength(1)); + + final firstPath = filePaths.first; + expect(firstPath, 'test/resources/file_paths_folder/second_file.dart'); + expect(firstPath, isNot(contains(rootFolder))); + }, + testOn: 'posix', + ); }); }