Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

fix: normalize file paths after extraction from analyzed folder #864

Merged
merged 4 commits into from Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/file_utils.dart
Expand Up @@ -23,5 +23,5 @@ Set<String> extractDartFilesFromFolders(
relative(entity.path, from: rootFolder),
globalExcludes,
))
.map((entity) => entity.path))
.map((entity) => normalize(entity.path)))
Copy link
Member

Choose a reason for hiding this comment

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

@incendial please cover by tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

.toSet();
19 changes: 19 additions & 0 deletions test/src/utils/analyzer_utils_test.dart
Expand Up @@ -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',
);
});
}