mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Use newAnalysisOptionsYamlFile() where possible.
Change-Id: I4b550cac941b6686738722cbcd3d04dfaabe5cdc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203081 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
91745979a6
commit
fe35fdd2c5
|
@ -116,7 +116,7 @@ pedantic:${pedanticFolder.toUri()}
|
|||
<uses-feature android:name="android.software.home_screen" />
|
||||
</manifest>
|
||||
''').path;
|
||||
newFile(join(projectPath, 'analysis_options.yaml'), content: '''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
optional-checks:
|
||||
chrome-os-manifest-checks: true
|
||||
|
@ -147,7 +147,7 @@ analyzer:
|
|||
<uses-feature android:name="android.software.home_screen" />
|
||||
</manifest>
|
||||
''').path;
|
||||
newFile(join(projectPath, 'analysis_options.yaml'), content: '''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
optional-checks:
|
||||
chrome-os-manifest-checks: true
|
||||
|
@ -271,7 +271,7 @@ transforms:
|
|||
}
|
||||
|
||||
Future<void> test_excludedFolder() async {
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
exclude:
|
||||
- excluded/**
|
||||
|
@ -320,7 +320,7 @@ import 'does_not_exist.dart';
|
|||
Future<void> test_lintError() async {
|
||||
var camelCaseTypesLintName = 'camel_case_types';
|
||||
|
||||
newFile(join(projectPath, 'analysis_options.yaml'), content: '''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
linter:
|
||||
rules:
|
||||
- $camelCaseTypesLintName
|
||||
|
@ -518,8 +518,7 @@ version: 1.3.2
|
|||
}
|
||||
|
||||
Future<void> test_pubspecFile_lint() async {
|
||||
var optionsPath = join(projectPath, 'analysis_options.yaml');
|
||||
newFile(optionsPath, content: '''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
linter:
|
||||
rules:
|
||||
- sort_pub_dependencies
|
||||
|
|
|
@ -62,12 +62,6 @@ class AbstractAnalysisTest with ResourceProviderMixin {
|
|||
|
||||
AnalysisDriver get testDiver => server.getAnalysisDriver(testFile)!;
|
||||
|
||||
void addAnalysisOptionsFile(String content) {
|
||||
newFile(
|
||||
resourceProvider.pathContext.join(projectPath, 'analysis_options.yaml'),
|
||||
content: content);
|
||||
}
|
||||
|
||||
void addAnalysisSubscription(AnalysisService service, String file) {
|
||||
// add file to subscription
|
||||
var files = analysisSubscriptions[service];
|
||||
|
@ -105,7 +99,7 @@ class AbstractAnalysisTest with ResourceProviderMixin {
|
|||
buffer.writeln(' - $experiment');
|
||||
}
|
||||
}
|
||||
addAnalysisOptionsFile(buffer.toString());
|
||||
newAnalysisOptionsYamlFile(projectPath, content: buffer.toString());
|
||||
}
|
||||
|
||||
AnalysisServer createAnalysisServer() {
|
||||
|
|
|
@ -162,7 +162,7 @@ class A {}
|
|||
test_setAnalysisSubscriptions_fileInIgnoredFolder_newOptions() async {
|
||||
var path = convertPath('/project/samples/sample.dart');
|
||||
newFile(path);
|
||||
newFile('/project/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile('/project', content: r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- 'samples/**'
|
||||
|
@ -183,7 +183,7 @@ analyzer:
|
|||
test_setAnalysisSubscriptions_fileInIgnoredFolder_oldOptions() async {
|
||||
var path = convertPath('/project/samples/sample.dart');
|
||||
newFile(path);
|
||||
newFile('/project/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile('/project', content: r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- 'samples/**'
|
||||
|
|
|
@ -364,7 +364,7 @@ class AnalysisDomainTest extends AbstractAnalysisTest {
|
|||
);
|
||||
|
||||
// Write the options file that excludes b.dart
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- lib/b.dart
|
||||
|
@ -416,7 +416,7 @@ analyzer:
|
|||
|
||||
newFile('$testPackageLibPath/a.dart', content: '');
|
||||
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: '''
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
|
||||
analyzer:
|
||||
optional-checks:
|
||||
chrome-os-manifest-checks: true
|
||||
|
@ -485,7 +485,7 @@ class A {}
|
|||
var a_path = '$projectPath/lib/a.dart';
|
||||
var b_path = '$projectPath/lib/b.dart';
|
||||
|
||||
newFile('$projectPath/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- "**/a.dart"
|
||||
|
@ -621,7 +621,7 @@ void f(A a) {}
|
|||
|
||||
// Write an empty file to force a new analysis context.
|
||||
// We look for `pubspec.yaml` files only in analysis context roots.
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: '');
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: '');
|
||||
|
||||
setRoots(included: [workspaceRootPath], excluded: []);
|
||||
await server.onAnalysisComplete;
|
||||
|
@ -723,7 +723,7 @@ analyzer:
|
|||
// Has an error - no touch screen.
|
||||
newFile(path, content: '<manifest/>');
|
||||
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: '''
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
|
||||
analyzer:
|
||||
optional-checks:
|
||||
chrome-os-manifest-checks: true
|
||||
|
@ -814,7 +814,7 @@ class A {}
|
|||
var a_path = '$testPackageLibPath/a.dart';
|
||||
var b_path = '$testPackageLibPath/b.dart';
|
||||
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- "**/a.dart"
|
||||
|
@ -1006,7 +1006,7 @@ analyzer:
|
|||
// Has an error - no touch screen.
|
||||
newFile(path, content: '<manifest/>');
|
||||
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: '''
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
|
||||
analyzer:
|
||||
optional-checks:
|
||||
chrome-os-manifest-checks: true
|
||||
|
@ -1049,7 +1049,7 @@ analyzer:
|
|||
var a_path = '$testPackageLibPath/a.dart';
|
||||
var b_path = '$testPackageLibPath/b.dart';
|
||||
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- "**/a.dart"
|
||||
|
@ -1349,7 +1349,7 @@ analyzer:
|
|||
|
||||
newFile('$testPackageLibPath/a.dart', content: '');
|
||||
|
||||
newFile('$testPackageRootPath/analysis_options.yaml', content: '''
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
|
||||
analyzer:
|
||||
optional-checks:
|
||||
chrome-os-manifest-checks: true
|
||||
|
|
|
@ -110,7 +110,7 @@ const double myDouble = 42.0;
|
|||
|
||||
Future<void> test_excludedSource() async {
|
||||
// Add analysis options to exclude the lib directory then reanalyze
|
||||
newFile('/project/analysis_options.yaml', content: '''
|
||||
newAnalysisOptionsYamlFile('/project', content: '''
|
||||
analyzer:
|
||||
exclude:
|
||||
- lib/**
|
||||
|
|
|
@ -60,7 +60,7 @@ class BulkFixesTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
Future<void> test_annotateOverrides_excludedFile() async {
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
exclude:
|
||||
- test/**
|
||||
|
@ -83,7 +83,7 @@ class B extends A {
|
|||
|
||||
Future<void> test_annotateOverrides_excludedSubProject() async {
|
||||
// Root project.
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
exclude:
|
||||
- test/data/**
|
||||
|
@ -147,7 +147,7 @@ class B extends A {
|
|||
}
|
||||
|
||||
Future<void> test_details() async {
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
linter:
|
||||
rules:
|
||||
- annotate_overrides
|
||||
|
@ -181,7 +181,7 @@ A f() => new A();
|
|||
}
|
||||
|
||||
Future<void> test_unnecessaryNew() async {
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
linter:
|
||||
rules:
|
||||
- unnecessary_new
|
||||
|
@ -205,7 +205,7 @@ A f() => A();
|
|||
if (Platform.isWindows) {
|
||||
fail('Should not be passing on Windows, but it does');
|
||||
}
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
linter:
|
||||
rules:
|
||||
- prefer_collection_literals
|
||||
|
@ -228,7 +228,7 @@ class A {
|
|||
}
|
||||
|
||||
Future<void> test_unnecessaryNew_ignoredInOptions() async {
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
errors:
|
||||
unnecessary_new: ignore
|
||||
|
@ -244,7 +244,7 @@ A f() => new A();
|
|||
}
|
||||
|
||||
Future<void> test_unnecessaryNew_ignoredInSource() async {
|
||||
addAnalysisOptionsFile('''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
linter:
|
||||
rules:
|
||||
- unnecessary_new
|
||||
|
|
|
@ -195,7 +195,7 @@ class MyAnnotation {
|
|||
}
|
||||
|
||||
Future<void> test_OK_genericFunctionType() async {
|
||||
newFile('$projectPath/analysis_options.yaml', content: '''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
strong-mode: true
|
||||
''');
|
||||
|
|
|
@ -263,7 +263,7 @@ class UriContributorTest extends DartCompletionContributorTest {
|
|||
Future<void> test_import_only_dart_files() async {
|
||||
testFile = convertPath('$testPackageRootPath/test.dart');
|
||||
newFile('$testPackageRootPath/other.dart');
|
||||
newFile('$testPackageRootPath/analysis_options.yaml');
|
||||
newAnalysisOptionsYamlFile(testPackageRootPath);
|
||||
|
||||
addTestSource('import "package:^";');
|
||||
await computeSuggestions();
|
||||
|
|
|
@ -75,7 +75,7 @@ class FlutterNotificationOutlineTest extends AbstractAnalysisTest {
|
|||
newDotPackagesFile(projectPath, content: '''
|
||||
flutter:${flutterFolder.toUri()}
|
||||
''');
|
||||
newFile('$projectPath/analysis_options.yaml', content: '''
|
||||
newAnalysisOptionsYamlFile(projectPath, content: '''
|
||||
analyzer:
|
||||
strong-mode: true
|
||||
''');
|
||||
|
|
|
@ -235,7 +235,7 @@ int b = a;
|
|||
}
|
||||
|
||||
test_analysisOptions_file_inPackage() async {
|
||||
newFile('/workspace/dart/test/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile('/workspace/dart/test', content: r'''
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
|
@ -257,8 +257,7 @@ analyzer:
|
|||
implicit-casts: false
|
||||
''');
|
||||
|
||||
newFile('/workspace/thid_party/dart/aaa/analysis_options.yaml',
|
||||
content: r'''
|
||||
newAnalysisOptionsYamlFile('/workspace/third_party/dart/aaa', content: r'''
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: true
|
||||
|
@ -281,7 +280,7 @@ analyzer:
|
|||
implicit-casts: false
|
||||
''');
|
||||
|
||||
newFile('/workspace/thid_party/dart_lang/aaa/analysis_options.yaml',
|
||||
newAnalysisOptionsYamlFile('/workspace/third_party/dart_lang/aaa',
|
||||
content: r'''
|
||||
analyzer:
|
||||
strong-mode:
|
||||
|
@ -1114,14 +1113,14 @@ int b = a;
|
|||
|
||||
test_reuse_incompatibleOptions_implicitCasts() async {
|
||||
newFile('/workspace/dart/aaa/BUILD', content: '');
|
||||
newFile('/workspace/dart/aaa/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile('/workspace/dart/aaa', content: r'''
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
''');
|
||||
|
||||
newFile('/workspace/dart/bbb/BUILD', content: '');
|
||||
newFile('/workspace/dart/bbb/analysis_options.yaml', content: r'''
|
||||
newAnalysisOptionsYamlFile('/workspace/dart/bbb', content: r'''
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: true
|
||||
|
|
|
@ -297,8 +297,8 @@ class PubPackageResolutionTest extends ContextResolutionTest {
|
|||
}
|
||||
|
||||
void writeTestPackageAnalysisOptionsFile(AnalysisOptionsFileConfig config) {
|
||||
newFile(
|
||||
'$testPackageRootPath/analysis_options.yaml',
|
||||
newAnalysisOptionsYamlFile(
|
||||
testPackageRootPath,
|
||||
content: config.toContent(),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue