diff --git a/pkg/dartdev/analysis_options.yaml b/pkg/dartdev/analysis_options.yaml index 84a5e26f95d..bafc96065de 100644 --- a/pkg/dartdev/analysis_options.yaml +++ b/pkg/dartdev/analysis_options.yaml @@ -1 +1,14 @@ include: package:pedantic/analysis_options.1.8.0.yaml + +analyzer: + errors: + # Increase the severity of several hints. + prefer_single_quotes: warning + unused_import: warning + unnecessary_brace_in_string_interps: warning + +linter: + rules: + - directives_ordering + - prefer_single_quotes + - unnecessary_brace_in_string_interps diff --git a/pkg/dartdev/lib/src/commands/analyze.dart b/pkg/dartdev/lib/src/commands/analyze.dart index 8965b452679..30b096f642b 100644 --- a/pkg/dartdev/lib/src/commands/analyze.dart +++ b/pkg/dartdev/lib/src/commands/analyze.dart @@ -32,7 +32,7 @@ class AnalyzeCommand extends DartdevCommand { @override FutureOr run() async { if (argResults.rest.length > 1) { - usageException("Only one directory is expected."); + usageException('Only one directory is expected.'); } // find directory from argResults.rest diff --git a/pkg/dartdev/test/commands/analyze_test.dart b/pkg/dartdev/test/commands/analyze_test.dart index 4be7ba64d3c..ba4d0b53037 100644 --- a/pkg/dartdev/test/commands/analyze_test.dart +++ b/pkg/dartdev/test/commands/analyze_test.dart @@ -87,10 +87,10 @@ void defineAnalyze() { expect(result.exitCode, 3); expect(result.stderr, isEmpty); - expect(result.stdout, contains("A value of type ")); - expect(result.stdout, contains("lib/main.dart:1:16 ")); - expect(result.stdout, contains("return_of_invalid_type")); - expect(result.stdout, contains("1 issue found.")); + expect(result.stdout, contains('A value of type ')); + expect(result.stdout, contains('lib/main.dart:1:16 ')); + expect(result.stdout, contains('return_of_invalid_type')); + expect(result.stdout, contains('1 issue found.')); }); test('two errors', () { @@ -99,7 +99,7 @@ void defineAnalyze() { expect(result.exitCode, 3); expect(result.stderr, isEmpty); - expect(result.stdout, contains("2 issues found.")); + expect(result.stdout, contains('2 issues found.')); }); test('warning --fatal-warnings', () { @@ -110,7 +110,7 @@ void defineAnalyze() { // should be exitCode == 2, not greater than 0: expect(result.exitCode, greaterThan(0)); expect(result.stderr, isEmpty); - expect(result.stdout, contains("1 issue found.")); + expect(result.stdout, contains('1 issue found.')); }); test('warning implicit --fatal-warnings', () { @@ -121,7 +121,7 @@ void defineAnalyze() { // should be exitCode == 2, not greater than 0: expect(result.exitCode, greaterThan(0)); expect(result.stderr, isEmpty); - expect(result.stdout, contains("1 issue found.")); + expect(result.stdout, contains('1 issue found.')); }); test('warning --no-fatal-warnings', () { @@ -132,24 +132,24 @@ void defineAnalyze() { // should be exitCode == 0: // expect(result.exitCode, 0); expect(result.stderr, isEmpty); - expect(result.stdout, contains("1 issue found.")); + expect(result.stdout, contains('1 issue found.')); }); test('info implicit no --fatal-infos', () { - p = project(mainSrc: "String foo() {}"); + p = project(mainSrc: 'String foo() {}'); var result = p.runSync('analyze', [p.dirPath]); expect(result.exitCode, 0); expect(result.stderr, isEmpty); - expect(result.stdout, contains("1 issue found.")); + expect(result.stdout, contains('1 issue found.')); }); test('info --fatal-infos', () { - p = project(mainSrc: "String foo() {}"); + p = project(mainSrc: 'String foo() {}'); var result = p.runSync('analyze', ['--fatal-infos', p.dirPath]); expect(result.exitCode, 1); expect(result.stderr, isEmpty); - expect(result.stdout, contains("1 issue found.")); + expect(result.stdout, contains('1 issue found.')); }); } diff --git a/pkg/dartdev/test/commands/format_test.dart b/pkg/dartdev/test/commands/format_test.dart index 4d8ed8ff457..74c5c50e566 100644 --- a/pkg/dartdev/test/commands/format_test.dart +++ b/pkg/dartdev/test/commands/format_test.dart @@ -75,7 +75,7 @@ void format() { ProcessResult result = p.runSync('format', [unknownFilePath]); expect(result.exitCode, 0); expect(result.stderr, - startsWith('No file or directory found at "${unknownFilePath}".')); + startsWith('No file or directory found at "$unknownFilePath".')); expect(result.stdout, isEmpty); }); } diff --git a/pkg/dartfix/analysis_options.yaml b/pkg/dartfix/analysis_options.yaml index bef508c815c..bfb45bf3a1d 100644 --- a/pkg/dartfix/analysis_options.yaml +++ b/pkg/dartfix/analysis_options.yaml @@ -6,6 +6,7 @@ analyzer: errors: # Increase the severity of the unused_import hint. unused_import: warning + unnecessary_brace_in_string_interps: warning # There are many pre-existing violations; this lint may not work well with # the Analyzer team's style. omit_local_variable_types: ignore diff --git a/pkg/dartfix/lib/src/migrate/migrate.dart b/pkg/dartfix/lib/src/migrate/migrate.dart index d008d1a14a5..621a03e5468 100644 --- a/pkg/dartfix/lib/src/migrate/migrate.dart +++ b/pkg/dartfix/lib/src/migrate/migrate.dart @@ -83,7 +83,7 @@ class MigrateCommand extends Command { instrumentationLogFile = path.join( Directory.systemTemp.createTempSync('migration_debug').path, 'instrumentationLog'); - logger.stdout('Instrumentation log file: ${instrumentationLogFile}'); + logger.stdout('Instrumentation log file: $instrumentationLogFile'); } Progress progress = getProgress('${ansi.emphasized('Analyzing project')}');