From 47ac47fe90cdc988278111efbcccd48f85ace1bf Mon Sep 17 00:00:00 2001 From: pq Date: Thu, 17 Mar 2022 23:41:27 +0000 Subject: [PATCH] lints 2.0 fixes In anticipation of lints v 2.0. (Note the ignores -- I was leery of making API changes but happy to with some guidance.) See: https://dart-review.googlesource.com/c/sdk/+/237746 Change-Id: I93323e912911bbd62a583b379f0f8140a8ca448d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237764 Reviewed-by: Ben Konyi Commit-Queue: Phil Quitslund --- pkg/native_stack_traces/bin/decode.dart | 6 +++--- pkg/native_stack_traces/lib/src/dwarf.dart | 20 ++++++++++++++----- pkg/vm_snapshot_analysis/lib/ascii_table.dart | 2 +- pkg/vm_snapshot_analysis/test/utils.dart | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pkg/native_stack_traces/bin/decode.dart b/pkg/native_stack_traces/bin/decode.dart index a7ca956d427..12c61ef7211 100644 --- a/pkg/native_stack_traces/bin/decode.dart +++ b/pkg/native_stack_traces/bin/decode.dart @@ -244,9 +244,9 @@ void find(ArgResults options) { final addr = dwarf.virtualAddressOf(offset); final frames = dwarf .callInfoFor(addr, includeInternalFrames: verbose) - ?.map((CallInfo c) => ' ' + c.toString()); + ?.map((CallInfo c) => ' $c'); final addrString = - addr > 0 ? '0x' + addr.toRadixString(16) : addr.toString(); + addr > 0 ? '0x${addr.toRadixString(16)}' : addr.toString(); print('For virtual address $addrString:'); if (frames == null) { print(' Invalid virtual address.'); @@ -283,7 +283,7 @@ Future translate(ArgResults options) async { .transform(utf8.decoder) .transform(const LineSplitter()) .transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: verbose)) - .map((s) => s + '\n') + .map((s) => '$s\n') .transform(utf8.encoder); await output.addStream(convertedStream); diff --git a/pkg/native_stack_traces/lib/src/dwarf.dart b/pkg/native_stack_traces/lib/src/dwarf.dart index 06ace824c1d..93a2af4cfb7 100644 --- a/pkg/native_stack_traces/lib/src/dwarf.dart +++ b/pkg/native_stack_traces/lib/src/dwarf.dart @@ -165,7 +165,7 @@ class _Attribute { case _AttributeForm.flag: return value.toString(); case _AttributeForm.address: - return '0x' + paddedHex(value as int, unit?.header.addressSize ?? 0); + return '0x${paddedHex(value as int, unit?.header.addressSize ?? 0)}'; case _AttributeForm.sectionOffset: return paddedHex(value as int, 4); case _AttributeForm.constant: @@ -274,6 +274,7 @@ class _AbbreviationsTable { class DebugInformationEntry { // The index of the entry in the abbreviation table for this DIE. final int code; + // ignore: library_private_types_in_public_api final Map<_Attribute, Object> attributes; final Map children; @@ -310,8 +311,10 @@ class DebugInformationEntry { return null; } + // ignore: library_private_types_in_public_api bool containsKey(_AttributeName name) => _namedAttribute(name) != null; + // ignore: library_private_types_in_public_api Object? operator [](_AttributeName name) => attributes[_namedAttribute(name)]; int? get sectionOffset => this[_AttributeName.statementList] as int?; @@ -408,7 +411,7 @@ class DebugInformationEntry { ..write(' (at offset 0x') ..write(paddedHex(offset)) ..writeln('):'); - child.writeToStringBuffer(buffer, unit: unit, indent: indent + ' '); + child.writeToStringBuffer(buffer, unit: unit, indent: '$indent '); } } } @@ -426,13 +429,16 @@ class CompilationUnitHeader { final int version; final int abbreviationsOffset; final int addressSize; + // ignore: library_private_types_in_public_api final _AbbreviationsTable abbreviations; CompilationUnitHeader._(this.size, this.version, this.abbreviationsOffset, this.addressSize, this.abbreviations); static CompilationUnitHeader? fromReader( - Reader reader, Map abbreviationsTables) { + Reader reader, + // ignore: library_private_types_in_public_api + Map abbreviationsTables) { final size = _initialLengthValue(reader); // An empty unit is an ending marker. if (size == 0) return null; @@ -481,7 +487,9 @@ class CompilationUnit { CompilationUnit._(this.header, this.referenceTable); static CompilationUnit? fromReader( - Reader reader, Map abbreviationsTables) { + Reader reader, + // ignore: library_private_types_in_public_api + Map abbreviationsTables) { final header = CompilationUnitHeader.fromReader(reader, abbreviationsTables); if (header == null) return null; @@ -553,7 +561,9 @@ class DebugInfo { DebugInfo._(this.units); static DebugInfo fromReader( - Reader reader, Map abbreviationsTable) { + Reader reader, + // ignore: library_private_types_in_public_api + Map abbreviationsTable) { final units = reader .readRepeated( (r) => CompilationUnit.fromReader(reader, abbreviationsTable)) diff --git a/pkg/vm_snapshot_analysis/lib/ascii_table.dart b/pkg/vm_snapshot_analysis/lib/ascii_table.dart index 4650ccadb3d..39455d8e6b0 100644 --- a/pkg/vm_snapshot_analysis/lib/ascii_table.dart +++ b/pkg/vm_snapshot_analysis/lib/ascii_table.dart @@ -102,7 +102,7 @@ class Text { String render(int width) { if (value.length > width) { // Narrowed column. - return value.substring(0, width - 2) + '..'; + return '${value.substring(0, width - 2)}..'; } switch (direction) { case AlignmentDirection.left: diff --git a/pkg/vm_snapshot_analysis/test/utils.dart b/pkg/vm_snapshot_analysis/test/utils.dart index 0d52b80dd10..cea4a7f7c78 100644 --- a/pkg/vm_snapshot_analysis/test/utils.dart +++ b/pkg/vm_snapshot_analysis/test/utils.dart @@ -91,7 +91,7 @@ stderr: ${result.stderr} }); } -late final shouldKeepTemporaryDirectories = +final shouldKeepTemporaryDirectories = Platform.environment['KEEP_TEMPORARY_DIRECTORIES']?.isNotEmpty == true; Future withTempDir(Future Function(String dir) f) async {