Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8329bd7

Browse files
keertipcommit-bot@chromium.org
authored andcommitted
Do not check for '.analysis_options' for default options file in builder.
Change-Id: I9decba4d0db318caedcfd3695f41c127b66f416f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138660 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]>
1 parent 4f0fb8f commit 8329bd7

File tree

15 files changed

+21
-198
lines changed

15 files changed

+21
-198
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ The Linter was updated to `0.1.112`, which includes:
147147
* new lint: `unnecessary_string_escapes`
148148
* incompatible rule documentation improvements
149149

150+
#### Analyzer
151+
152+
* Removed support for the deprecated analysis options file name `.analysis_options`.
153+
150154
#### Pub
151155

152156
* `pub get` and `pub upgrade` now fetches version information about hosted

pkg/analysis_server/lib/src/analysis_server_abstract.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ abstract class AbstractAnalysisServer {
7878
'**/*.${AnalysisEngine.SUFFIX_DART}',
7979
'**/*.${AnalysisEngine.SUFFIX_HTML}',
8080
'**/*.${AnalysisEngine.SUFFIX_HTM}',
81-
'**/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}',
8281
'**/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}',
8382
'**/${AnalysisEngine.PUBSPEC_YAML_FILE}',
8483
'**/${AnalysisEngine.ANDROID_MANIFEST_FILE}'

pkg/analysis_server/test/analysis/notification_analysis_options_test.dart

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ import '../analysis_abstract.dart';
1717

1818
void main() {
1919
defineReflectiveSuite(() {
20-
defineReflectiveTests(NewAnalysisOptionsFileNotificationTest);
21-
defineReflectiveTests(OldAnalysisOptionsFileNotificationTest);
20+
defineReflectiveTests(AnalysisOptionsFileNotificationTest);
2221
});
2322
}
2423

25-
abstract class AnalysisOptionsFileNotificationTest
26-
extends AbstractAnalysisTest {
24+
@reflectiveTest
25+
class AnalysisOptionsFileNotificationTest extends AbstractAnalysisTest {
2726
Map<String, List<AnalysisError>> filesErrors = {};
2827

2928
final testSource = '''
@@ -37,7 +36,7 @@ main() {
3736

3837
List<AnalysisError> get optionsFileErrors => filesErrors[optionsFilePath];
3938

40-
String get optionsFilePath;
39+
String get optionsFilePath => '$projectPath/analysis_options.yaml';
4140

4241
List<AnalysisError> get testFileErrors => filesErrors[testFile];
4342

@@ -260,17 +259,3 @@ linter:
260259
expect(rules, unorderedEquals(lints));
261260
}
262261
}
263-
264-
@reflectiveTest
265-
class NewAnalysisOptionsFileNotificationTest
266-
extends AnalysisOptionsFileNotificationTest {
267-
@override
268-
String get optionsFilePath => '$projectPath/analysis_options.yaml';
269-
}
270-
271-
@reflectiveTest
272-
class OldAnalysisOptionsFileNotificationTest
273-
extends AnalysisOptionsFileNotificationTest {
274-
@override
275-
String get optionsFilePath => '$projectPath/.analysis_options';
276-
}

pkg/analysis_server/test/analysis/notification_errors_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ import 'does_not_exist.dart';
200200
Future<void> test_lintError() async {
201201
var camelCaseTypesLintName = 'camel_case_types';
202202

203-
newFile(join(projectPath, '.analysis_options'), content: '''
203+
newFile(join(projectPath, 'analysis_options.yaml'), content: '''
204204
linter:
205205
rules:
206206
- $camelCaseTypesLintName

pkg/analysis_server/test/context_manager_test.dart

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ import 'src/plugin/plugin_manager_test.dart';
4343
void main() {
4444
defineReflectiveSuite(() {
4545
defineReflectiveTests(AbstractContextManagerTest);
46-
defineReflectiveTests(ContextManagerWithNewOptionsTest);
47-
defineReflectiveTests(ContextManagerWithOldOptionsTest);
46+
defineReflectiveTests(ContextManagerWithOptionsTest);
4847
});
4948
}
5049

@@ -1657,7 +1656,6 @@ abstract class ContextManagerTest with ResourceProviderMixin {
16571656
'**/*.${AnalysisEngine.SUFFIX_DART}',
16581657
'**/*.${AnalysisEngine.SUFFIX_HTML}',
16591658
'**/*.${AnalysisEngine.SUFFIX_HTM}',
1660-
'**/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}',
16611659
'**/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'
16621660
];
16631661
return patterns
@@ -1712,27 +1710,9 @@ abstract class ContextManagerTest with ResourceProviderMixin {
17121710
}
17131711

17141712
@reflectiveTest
1715-
class ContextManagerWithNewOptionsTest extends ContextManagerWithOptionsTest {
1716-
@override
1713+
class ContextManagerWithOptionsTest extends ContextManagerTest {
17171714
String get optionsFileName => AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE;
17181715

1719-
@override
1720-
@failingTest
1721-
Future<void> test_analysis_options_parse_failure() async {
1722-
// We have lost the ability to detect errors of this form.
1723-
return super.test_analysis_options_parse_failure();
1724-
}
1725-
}
1726-
1727-
@reflectiveTest
1728-
class ContextManagerWithOldOptionsTest extends ContextManagerWithOptionsTest {
1729-
@override
1730-
String get optionsFileName => AnalysisEngine.ANALYSIS_OPTIONS_FILE;
1731-
}
1732-
1733-
abstract class ContextManagerWithOptionsTest extends ContextManagerTest {
1734-
String get optionsFileName;
1735-
17361716
void deleteOptionsFile() {
17371717
deleteFile('$projPath/$optionsFileName');
17381718
}
@@ -1879,6 +1859,7 @@ include: package:boo/other_options.yaml
18791859
expect(lints[0].name, 'camel_case_types');
18801860
}
18811861

1862+
@failingTest
18821863
Future<void> test_analysis_options_parse_failure() async {
18831864
// Create files.
18841865
String libPath = '$projPath/${ContextManagerTest.LIB_NAME}';

pkg/analysis_server/test/integration/analysis/analysis_options_test.dart

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OptionsIntegrationTest extends AbstractAnalysisServerIntegrationTest {
2323
standardAnalysisSetup();
2424
}
2525

26-
Future<void> test_option_warning_newOptionFile() async {
26+
Future<void> test_option_warning_optionFile() async {
2727
String options = sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
2828
writeFile(options, '''
2929
linter:
@@ -47,31 +47,4 @@ linter:
4747
expect(error.location.startLine, 3);
4848
expect(error.location.startColumn, 7);
4949
}
50-
51-
Future<void> test_option_warning_oldOptionFile() async {
52-
String options = sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_FILE);
53-
writeFile(options, '''
54-
linter:
55-
rules:
56-
- camel_case_types
57-
''');
58-
59-
optionsAnalysisSetup();
60-
61-
await analysisFinished;
62-
63-
expect(currentAnalysisErrors[options], isList);
64-
List<AnalysisError> errors = currentAnalysisErrors[options];
65-
expect(errors, hasLength(1));
66-
AnalysisError error = errors[0];
67-
expect(error.location.file, options);
68-
expect(error.severity, AnalysisErrorSeverity.INFO);
69-
expect(error.type, AnalysisErrorType.HINT);
70-
expect(error.location.offset, 0);
71-
expect(error.location.length, 1);
72-
expect(error.location.startLine, 1);
73-
expect(error.location.startColumn, 1);
74-
expect(error.message,
75-
'The name of the analysis options file .analysis_options is deprecated; consider renaming it to analysis_options.yaml.');
76-
}
7750
}

pkg/analysis_server/test/integration/analysis/lint_test.dart

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class abc { // lint: not CamelCase (should get ignored though)
3131
expect(errors, hasLength(0));
3232
}
3333

34-
Future<void> test_simple_lint_newOptionsFile() async {
34+
Future<void> test_simple_lint_optionsFile() async {
3535
writeFile(sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE), '''
3636
linter:
3737
rules:
@@ -55,29 +55,4 @@ class a { // lint: not CamelCase
5555
expect(error.severity, AnalysisErrorSeverity.INFO);
5656
expect(error.type, AnalysisErrorType.LINT);
5757
}
58-
59-
Future<void> test_simple_lint_oldOptionsFile() async {
60-
writeFile(sourcePath(AnalysisEngine.ANALYSIS_OPTIONS_FILE), '''
61-
linter:
62-
rules:
63-
- camel_case_types
64-
''');
65-
66-
String source = sourcePath('test.dart');
67-
writeFile(source, '''
68-
class a { // lint: not CamelCase
69-
}''');
70-
71-
standardAnalysisSetup();
72-
73-
await analysisFinished;
74-
75-
expect(currentAnalysisErrors[source], isList);
76-
List<AnalysisError> errors = currentAnalysisErrors[source];
77-
expect(errors, hasLength(1));
78-
AnalysisError error = errors[0];
79-
expect(error.location.file, source);
80-
expect(error.severity, AnalysisErrorSeverity.INFO);
81-
expect(error.type, AnalysisErrorType.LINT);
82-
}
8358
}

pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ class AnalysisOptionsProvider {
2121

2222
AnalysisOptionsProvider([this.sourceFactory]);
2323

24-
/// Provide the options found in either
25-
/// [root]/[AnalysisEngine.ANALYSIS_OPTIONS_FILE] or
24+
/// Provide the options found in
2625
/// [root]/[AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE].
2726
/// Recursively merge options referenced by an include directive
2827
/// and remove the include directive from the resulting options map.
@@ -43,10 +42,6 @@ class AnalysisOptionsProvider {
4342
File getOptionsFile(Folder root, {bool crawlUp = false}) {
4443
Resource resource;
4544
for (Folder folder = root; folder != null; folder = folder.parent) {
46-
resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE);
47-
if (resource.exists) {
48-
break;
49-
}
5045
resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
5146
if (resource.exists || !crawlUp) {
5247
break;

pkg/analyzer/lib/src/context/builder.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,7 @@ class ContextBuilder {
378378
}
379379
Folder root = resourceProvider.getFolder(path);
380380
for (Folder folder = root; folder != null; folder = folder.parent) {
381-
File file =
382-
folder.getChildAssumingFile(AnalysisEngine.ANALYSIS_OPTIONS_FILE);
383-
if (file.exists) {
384-
return file;
385-
}
386-
file = folder
381+
File file = folder
387382
.getChildAssumingFile(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
388383
if (file.exists) {
389384
return file;

pkg/analyzer/lib/src/generated/engine.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ class AnalysisEngine {
111111
/// The long suffix used for HTML files.
112112
static const String SUFFIX_HTML = "html";
113113

114-
/// The deprecated file name used for analysis options files.
115-
static const String ANALYSIS_OPTIONS_FILE = '.analysis_options';
116-
117114
/// The file name used for analysis options files.
118115
static const String ANALYSIS_OPTIONS_YAML_FILE = 'analysis_options.yaml';
119116

@@ -166,8 +163,7 @@ class AnalysisEngine {
166163
return false;
167164
}
168165
String basename = (context ?? pathos.posix).basename(fileName);
169-
return basename == ANALYSIS_OPTIONS_FILE ||
170-
basename == ANALYSIS_OPTIONS_YAML_FILE;
166+
return basename == ANALYSIS_OPTIONS_YAML_FILE;
171167
}
172168

173169
/// Return `true` if the given [fileName] is assumed to contain Dart source

0 commit comments

Comments
 (0)