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

Commit 7d8269b

Browse files
author
Roman Petrov
authored
fix: fix rule-specific excludes not working on Windows (#518)
* fix: fix rule-specific excludes not working on Windows * docs: update changelog * test: make tests platform-specific * chore: update skipped test descriptions
1 parent d482eae commit 7d8269b

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
* fix: rule-specific excludes not working on Windows.
6+
37
## 4.5.0-dev.3
48

59
* fix: make check-unused-l10n report class fields.

lib/src/config_builder/models/analysis_options.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class AnalysisOptions {
2020

2121
const AnalysisOptions(this._path, this.options);
2222

23-
String? get folderPath => _path?.split('/$_analysisOptionsFileName').first;
23+
String? get folderPath {
24+
final finalPath = _path;
25+
26+
return finalPath == null ? null : p.dirname(finalPath);
27+
}
2428

2529
Iterable<String> readIterableOfString(Iterable<String> pathSegments) {
2630
Object? data = options;

test/config_builder/models/analysis_options_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,23 @@ void main() {
187187

188188
expect(options.readMapOfMap(['dart_code_metrics', 'rules4']), isEmpty);
189189
});
190+
191+
test('returns correct "folderPath" on posix platforms', () async {
192+
const options =
193+
AnalysisOptions('./unix/folder/analysis_options.yaml', {});
194+
195+
expect(options.folderPath, './unix/folder');
196+
}, onPlatform: <String, dynamic>{
197+
'windows': const Skip('Test should work only on posix platforms.')
198+
});
199+
200+
test('returns correct "folderPath" on windows platforms', () async {
201+
const options =
202+
AnalysisOptions(r'C:\windows\folder\analysis_options.yaml', {});
203+
204+
expect(options.folderPath, r'C:\windows\folder');
205+
}, onPlatform: <String, dynamic>{
206+
'posix': const Skip('Test should work only on windows platforms.')
207+
});
190208
});
191209
}

0 commit comments

Comments
 (0)