mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:01:19 +00:00
Enable prefer_single_quotes in analyzer_cli
Change-Id: I65bb9be8579ec9384d755b09b4b3aec4776c7ab6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132500 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
fdc8f08af9
commit
1cab712261
|
@ -44,7 +44,7 @@ linter:
|
|||
- prefer_is_empty
|
||||
- prefer_is_not_empty
|
||||
- prefer_iterable_whereType
|
||||
#- prefer_single_quotes # 59
|
||||
- prefer_single_quotes
|
||||
- prefer_spread_collections
|
||||
- recursive_getters
|
||||
- slash_for_doc_comments
|
||||
|
|
|
@ -26,9 +26,9 @@ int get currentTimeMillis => DateTime.now().millisecondsSinceEpoch;
|
|||
/// Analyzes single library [File].
|
||||
class AnalyzerImpl {
|
||||
static final PerformanceTag _prepareErrorsTag =
|
||||
PerformanceTag("AnalyzerImpl.prepareErrors");
|
||||
PerformanceTag('AnalyzerImpl.prepareErrors');
|
||||
static final PerformanceTag _resolveLibraryTag =
|
||||
PerformanceTag("AnalyzerImpl._resolveLibrary");
|
||||
PerformanceTag('AnalyzerImpl._resolveLibrary');
|
||||
|
||||
final CommandLineOptions options;
|
||||
final int startTime;
|
||||
|
@ -158,8 +158,8 @@ class AnalyzerImpl {
|
|||
// Don't try to analyze parts.
|
||||
if (libraryFile.isPart) {
|
||||
String libraryPath = libraryFile.path;
|
||||
stderr.writeln("Only libraries can be analyzed.");
|
||||
stderr.writeln("$libraryPath is a part and can not be analyzed.");
|
||||
stderr.writeln('Only libraries can be analyzed.');
|
||||
stderr.writeln('$libraryPath is a part and cannot be analyzed.');
|
||||
return ErrorSeverity.ERROR;
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ class AnalyzerImpl {
|
|||
}
|
||||
}
|
||||
outSink.writeln('other-cold:$otherTime');
|
||||
outSink.writeln("total-cold:$totalTime");
|
||||
outSink.writeln('total-cold:$totalTime');
|
||||
}
|
||||
|
||||
Future<LibraryElement> _resolveLibrary() async {
|
||||
|
|
|
@ -67,7 +67,7 @@ bool containsLintRuleEntry(YamlMap options) {
|
|||
|
||||
class Driver with HasContextMixin implements CommandLineStarter {
|
||||
static final PerformanceTag _analyzeAllTag =
|
||||
PerformanceTag("Driver._analyzeAll");
|
||||
PerformanceTag('Driver._analyzeAll');
|
||||
|
||||
static final ByteStore analysisDriverMemoryByteStore = MemoryByteStore();
|
||||
|
||||
|
@ -115,7 +115,7 @@ class Driver with HasContextMixin implements CommandLineStarter {
|
|||
@override
|
||||
Future<void> start(List<String> args, {SendPort sendPort}) async {
|
||||
if (analysisDriver != null) {
|
||||
throw StateError("start() can only be called once");
|
||||
throw StateError('start() can only be called once');
|
||||
}
|
||||
int startTime = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
|
@ -235,8 +235,8 @@ class Driver with HasContextMixin implements CommandLineStarter {
|
|||
ErrorSeverity allResult = ErrorSeverity.NONE;
|
||||
|
||||
void reportPartError(String partPath) {
|
||||
errorSink.writeln("$partPath is a part and cannot be analyzed.");
|
||||
errorSink.writeln("Please pass in a library that contains this part.");
|
||||
errorSink.writeln('$partPath is a part and cannot be analyzed.');
|
||||
errorSink.writeln('Please pass in a library that contains this part.');
|
||||
io.exitCode = ErrorSeverity.ERROR.ordinal;
|
||||
allResult = allResult.max(ErrorSeverity.ERROR);
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ class Driver with HasContextMixin implements CommandLineStarter {
|
|||
|
||||
/// Returns `true` if this relative path is a hidden directory.
|
||||
bool _isInHiddenDir(String relative) =>
|
||||
path.split(relative).any((part) => part.startsWith("."));
|
||||
path.split(relative).any((part) => part.startsWith('.'));
|
||||
|
||||
/// Analyze a single source.
|
||||
Future<ErrorSeverity> _runAnalyzer(
|
||||
|
|
|
@ -19,7 +19,7 @@ final Map<String, int> _severityCompare = {
|
|||
'hint': 1,
|
||||
};
|
||||
|
||||
String _pluralize(String word, int count) => count == 1 ? word : word + "s";
|
||||
String _pluralize(String word, int count) => count == 1 ? word : word + 's';
|
||||
|
||||
/// Given an absolute path, return a relative path if the file is contained in
|
||||
/// the current directory; return the original path otherwise.
|
||||
|
@ -60,7 +60,7 @@ class AnalysisStats {
|
|||
if (hasErrors) {
|
||||
out.write(errorCount);
|
||||
out.write(' ');
|
||||
out.write(_pluralize("error", errorCount));
|
||||
out.write(_pluralize('error', errorCount));
|
||||
hasContent = true;
|
||||
}
|
||||
if (hasWarns) {
|
||||
|
@ -68,12 +68,12 @@ class AnalysisStats {
|
|||
if (!hasHints && !hasLints) {
|
||||
out.write(' and ');
|
||||
} else {
|
||||
out.write(", ");
|
||||
out.write(', ');
|
||||
}
|
||||
}
|
||||
out.write(warnCount);
|
||||
out.write(' ');
|
||||
out.write(_pluralize("warning", warnCount));
|
||||
out.write(_pluralize('warning', warnCount));
|
||||
hasContent = true;
|
||||
}
|
||||
if (hasLints) {
|
||||
|
@ -82,22 +82,22 @@ class AnalysisStats {
|
|||
}
|
||||
out.write(lintCount);
|
||||
out.write(' ');
|
||||
out.write(_pluralize("lint", lintCount));
|
||||
out.write(_pluralize('lint', lintCount));
|
||||
hasContent = true;
|
||||
}
|
||||
if (hasHints) {
|
||||
if (hasContent) {
|
||||
out.write(" and ");
|
||||
out.write(' and ');
|
||||
}
|
||||
out.write(hintCount);
|
||||
out.write(' ');
|
||||
out.write(_pluralize("hint", hintCount));
|
||||
out.write(_pluralize('hint', hintCount));
|
||||
hasContent = true;
|
||||
}
|
||||
if (hasContent) {
|
||||
out.writeln(" found.");
|
||||
out.writeln(' found.');
|
||||
} else {
|
||||
out.writeln("No issues found!");
|
||||
out.writeln('No issues found!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ class CommandLineOptions {
|
|||
return versionFile.readAsStringSync().trim();
|
||||
} catch (_) {
|
||||
// This happens when the script is not running in the context of an SDK.
|
||||
return "<unknown>";
|
||||
return '<unknown>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,8 +470,8 @@ class CommandLineOptions {
|
|||
hide: hide,
|
||||
negatable: true)
|
||||
..addFlag('train-snapshot',
|
||||
help: "Analyze the given source for the purposes of training a "
|
||||
"dartanalyzer snapshot.",
|
||||
help: 'Analyze the given source for the purposes of training a '
|
||||
'dartanalyzer snapshot.',
|
||||
hide: hide,
|
||||
negatable: false);
|
||||
|
||||
|
|
|
@ -10,19 +10,19 @@ import 'package:analyzer/src/generated/utilities_general.dart'
|
|||
import 'package:analyzer_cli/src/error_formatter.dart';
|
||||
import 'package:analyzer_cli/src/options.dart' show CommandLineOptions;
|
||||
|
||||
const _JSON = JsonEncoder.withIndent(" ");
|
||||
const _JSON = JsonEncoder.withIndent(' ');
|
||||
|
||||
final String _osType = () {
|
||||
if (Platform.isLinux) {
|
||||
return "linux";
|
||||
return 'linux';
|
||||
} else if (Platform.isMacOS) {
|
||||
return "mac";
|
||||
return 'mac';
|
||||
} else if (Platform.isWindows) {
|
||||
return "windows";
|
||||
return 'windows';
|
||||
} else if (Platform.isAndroid) {
|
||||
return "android";
|
||||
return 'android';
|
||||
} else {
|
||||
return "unknown";
|
||||
return 'unknown';
|
||||
}
|
||||
}();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class OptionsTest {
|
|||
'analysis_options_user.yaml');
|
||||
expect(FileSystemEntity.isFileSync(expectedPath), isTrue);
|
||||
await runner.run2([
|
||||
"--packages",
|
||||
'--packages',
|
||||
path.join(tempDirPath, 'packagelist'),
|
||||
path.join(tempDirPath, 'lib', 'main.dart')
|
||||
]);
|
||||
|
@ -78,7 +78,7 @@ class _Runner {
|
|||
Future<void> run2(List<String> args) async {
|
||||
await Driver(isTesting: true).start(args);
|
||||
if (stderr.isNotEmpty) {
|
||||
fail("Unexpected output to stderr:\n$stderr");
|
||||
fail('Unexpected output to stderr:\n$stderr');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -934,7 +934,7 @@ analyzer:
|
|||
expect(
|
||||
bulletToDash(outSink),
|
||||
contains(
|
||||
"warning - The feature android.software.home_screen is not supported on Chrome OS"));
|
||||
'warning - The feature android.software.home_screen is not supported on Chrome OS'));
|
||||
expect(exitCode, 0);
|
||||
});
|
||||
}
|
||||
|
@ -1023,7 +1023,7 @@ class OptionsTest extends BaseTest {
|
|||
expect(processorFor(missing_return).severity, ErrorSeverity.ERROR);
|
||||
expect(bulletToDash(outSink),
|
||||
contains("error - This function has a return type of 'int'"));
|
||||
expect(outSink.toString(), contains("1 error and 1 warning found."));
|
||||
expect(outSink.toString(), contains('1 error and 1 warning found.'));
|
||||
}
|
||||
|
||||
test_includeDirective() async {
|
||||
|
@ -1064,7 +1064,7 @@ class OptionsTest extends BaseTest {
|
|||
// Should not be made fatal by `--fatal-warnings`.
|
||||
expect(bulletToDash(outSink),
|
||||
contains("warning - The function 'baz' isn't defined"));
|
||||
expect(outSink.toString(), contains("1 error and 1 warning found."));
|
||||
expect(outSink.toString(), contains('1 error and 1 warning found.'));
|
||||
}
|
||||
|
||||
Future<void> _driveBasic() async {
|
||||
|
@ -1077,7 +1077,7 @@ class OptionsTest extends BaseTest {
|
|||
contains("error - Undefined class 'IncludedUndefinedClass'"));
|
||||
expect(bulletToDash(outSink),
|
||||
isNot(contains("error - Undefined class 'ExcludedUndefinedClass'")));
|
||||
expect(outSink.toString(), contains("1 error found."));
|
||||
expect(outSink.toString(), contains('1 error found.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ main() {
|
|||
equals("Cannot specify both '--package-root' and '--packages."));
|
||||
});
|
||||
|
||||
test("bad SDK dir", () {
|
||||
test('bad SDK dir', () {
|
||||
var failureMessage;
|
||||
CommandLineOptions.parse(['--dart-sdk', '&&&&&', 'foo.dart'],
|
||||
printAndFail: (msg) => failureMessage = msg);
|
||||
|
|
|
@ -27,9 +27,9 @@ main() {
|
|||
|
||||
test('shows only the hint whose package matches the prefix', () async {
|
||||
await runner.run2([
|
||||
"--packages",
|
||||
'--packages',
|
||||
join(testDirectory, 'data', 'package_prefix', 'packagelist'),
|
||||
"--x-package-warnings-prefix=f",
|
||||
'--x-package-warnings-prefix=f',
|
||||
join(testDirectory, 'data', 'package_prefix', 'main.dart')
|
||||
]);
|
||||
expect(runner.stdout, contains('1 hint found'));
|
||||
|
@ -67,7 +67,7 @@ class _Runner {
|
|||
Future<void> run2(List<String> args) async {
|
||||
await Driver(isTesting: true).start(args);
|
||||
if (stderr.isNotEmpty) {
|
||||
fail("Unexpected output to stderr:\n$stderr");
|
||||
fail('Unexpected output to stderr:\n$stderr');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ import 'package:test/test.dart';
|
|||
|
||||
main() {
|
||||
test('makePerfReport', () {
|
||||
var options = CommandLineOptions.parse(["somefile.dart"]);
|
||||
var options = CommandLineOptions.parse(['somefile.dart']);
|
||||
var encoded = makePerfReport(1000, 1234, options, 0, AnalysisStats());
|
||||
|
||||
var jsonData = json.decode(encoded);
|
||||
expect(jsonData['totalElapsedTime'], 234);
|
||||
expect(jsonData['options']['sourceFiles'], ["somefile.dart"]);
|
||||
expect(jsonData['options']['sourceFiles'], ['somefile.dart']);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ main(List<String> args) async {
|
|||
}
|
||||
|
||||
totalTimer.stop();
|
||||
report("total", totalTimer.elapsedMicroseconds);
|
||||
report('total', totalTimer.elapsedMicroseconds);
|
||||
}
|
||||
|
||||
/// Cumulative time spent scanning.
|
||||
|
@ -106,10 +106,10 @@ void parseFiles(Set<Source> files) {
|
|||
|
||||
// Report size and scanning time again. See discussion above.
|
||||
if (old != scanTotalChars) print('input size changed? $old chars');
|
||||
report("scan", scanTimer.elapsedMicroseconds);
|
||||
report('scan', scanTimer.elapsedMicroseconds);
|
||||
|
||||
var pTime = parseTimer.elapsedMicroseconds - scanTimer.elapsedMicroseconds;
|
||||
report("parse", pTime);
|
||||
report('parse', pTime);
|
||||
}
|
||||
|
||||
/// Parse the full body of [source] and return it's compilation unit.
|
||||
|
@ -145,7 +145,7 @@ void scanFiles(Set<Source> files) {
|
|||
|
||||
// Report size and scanning time again. See discussion above.
|
||||
if (old != scanTotalChars) print('input size changed? $old chars');
|
||||
report("scan", scanTimer.elapsedMicroseconds);
|
||||
report('scan', scanTimer.elapsedMicroseconds);
|
||||
}
|
||||
|
||||
/// Load and scans all files we need to process: files reachable from the
|
||||
|
@ -156,18 +156,18 @@ Set<Source> scanReachableFiles(Uri entryUri) {
|
|||
collectSources(sources.forUri2(entryUri), files);
|
||||
|
||||
var libs = [
|
||||
"dart:async",
|
||||
"dart:cli",
|
||||
"dart:collection",
|
||||
"dart:convert",
|
||||
"dart:core",
|
||||
"dart:developer",
|
||||
"dart:_internal",
|
||||
"dart:isolate",
|
||||
"dart:math",
|
||||
"dart:mirrors",
|
||||
"dart:typed_data",
|
||||
"dart:io",
|
||||
'dart:async',
|
||||
'dart:cli',
|
||||
'dart:collection',
|
||||
'dart:convert',
|
||||
'dart:core',
|
||||
'dart:developer',
|
||||
'dart:_internal',
|
||||
'dart:isolate',
|
||||
'dart:math',
|
||||
'dart:mirrors',
|
||||
'dart:typed_data',
|
||||
'dart:io',
|
||||
];
|
||||
|
||||
for (var lib in libs) {
|
||||
|
@ -178,8 +178,8 @@ Set<Source> scanReachableFiles(Uri entryUri) {
|
|||
|
||||
print('input size: $scanTotalChars chars');
|
||||
var loadTime = loadTimer.elapsedMicroseconds - scanTimer.elapsedMicroseconds;
|
||||
report("load", loadTime);
|
||||
report("scan", scanTimer.elapsedMicroseconds);
|
||||
report('load', loadTime);
|
||||
report('scan', scanTimer.elapsedMicroseconds);
|
||||
return files;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ Future setup(String path) async {
|
|||
sources = SourceFactory([
|
||||
ResourceUriResolver(provider),
|
||||
PackageMapUriResolver(provider, packageMap),
|
||||
DartUriResolver(FolderBasedDartSdk(provider, provider.getFolder("sdk"))),
|
||||
DartUriResolver(FolderBasedDartSdk(provider, provider.getFolder('sdk'))),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue