[dartdev] address a few analysis issues

Change-Id: I546a88aeed31a3e7349a45825087e3bed4720559
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138913
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
Devon Carew
2020-03-10 20:07:51 +00:00
committed by commit-bot@chromium.org
parent 699f4b7395
commit 41cb842cb2
6 changed files with 29 additions and 15 deletions
+13
View File
@@ -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
+1 -1
View File
@@ -32,7 +32,7 @@ class AnalyzeCommand extends DartdevCommand<int> {
@override
FutureOr<int> run() async {
if (argResults.rest.length > 1) {
usageException("Only one directory is expected.");
usageException('Only one directory is expected.');
}
// find directory from argResults.rest
+12 -12
View File
@@ -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.'));
});
}
+1 -1
View File
@@ -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);
});
}
+1
View File
@@ -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
+1 -1
View File
@@ -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')}');