pkg:native_stack_trace - enable and fix a few more lints

Change-Id: I1c0c572bc87480a8f935c51965423f0d5fbe6d0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216692
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Kevin Moore 2021-10-14 07:35:43 +00:00 committed by commit-bot@chromium.org
parent b0874f26b7
commit 3816e247c5
6 changed files with 35 additions and 44 deletions

View file

@ -1 +1,8 @@
include: package:lints/recommended.yaml
linter:
rules:
- avoid_dynamic_calls
- directives_ordering
- prefer_expression_function_bodies
- sort_pub_dependencies

View file

@ -7,8 +7,8 @@ import 'dart:convert';
import 'dart:io' as io;
import 'package:args/args.dart' show ArgParser, ArgResults;
import 'package:path/path.dart' as path;
import 'package:native_stack_traces/native_stack_traces.dart';
import 'package:path/path.dart' as path;
ArgParser _createBaseDebugParser(ArgParser parser) => parser
..addOption('debug',
@ -230,7 +230,10 @@ void find(ArgResults options) {
final header = StackTraceHeader(isolateStart, vmStart);
final locations = <PCOffset>[];
for (final String s in options['location'] + options.rest) {
for (final String s in [
...(options['location'] as List<String>),
...options.rest,
]) {
final location = convertAddress(header, s);
if (location == null) return usageError('could not parse PC address $s');
locations.add(location);

View file

@ -2,10 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
export 'src/elf.dart' show DynamicTable, DynamicTableTag, Elf, Section, Symbol;
export 'src/constants.dart'
show
isolateDataSymbolName,
isolateSymbolName,
vmDataSymbolName,
vmSymbolName;
export 'src/elf.dart' show DynamicTable, DynamicTableTag, Elf, Section, Symbol;

View file

@ -1104,17 +1104,14 @@ class DartCallInfo extends CallInfo {
);
@override
bool operator ==(Object other) {
if (other is DartCallInfo) {
return inlined == other.inlined &&
internal == other.internal &&
function == other.function &&
filename == other.filename &&
line == other.line &&
column == other.column;
}
return false;
}
bool operator ==(Object other) =>
other is DartCallInfo &&
inlined == other.inlined &&
internal == other.internal &&
function == other.function &&
filename == other.filename &&
line == other.line &&
column == other.column;
void writeToStringBuffer(StringBuffer buffer) {
buffer
@ -1153,12 +1150,8 @@ class StubCallInfo extends CallInfo {
int get hashCode => Object.hash(name, offset);
@override
bool operator ==(Object other) {
if (other is StubCallInfo) {
return name == other.name && offset == other.offset;
}
return false;
}
bool operator ==(Object other) =>
other is StubCallInfo && name == other.name && offset == other.offset;
@override
String toString() => '$name+0x${offset.toRadixString(16)}';
@ -1193,11 +1186,8 @@ class PCOffset {
int get hashCode => Object.hash(offset, section);
@override
bool operator ==(Object other) {
return other is PCOffset &&
offset == other.offset &&
section == other.section;
}
bool operator ==(Object other) =>
other is PCOffset && offset == other.offset && section == other.section;
@override
String toString() => 'PCOffset($section, $offset)';

View file

@ -18,24 +18,18 @@ int _readElfBytes(Reader reader, int bytes, int alignment) {
}
// Reads an Elf{32,64}_Addr.
int _readElfAddress(Reader reader) {
return _readElfBytes(reader, reader.wordSize, reader.wordSize);
}
int _readElfAddress(Reader reader) =>
_readElfBytes(reader, reader.wordSize, reader.wordSize);
// Reads an Elf{32,64}_Off.
int _readElfOffset(Reader reader) {
return _readElfBytes(reader, reader.wordSize, reader.wordSize);
}
int _readElfOffset(Reader reader) =>
_readElfBytes(reader, reader.wordSize, reader.wordSize);
// Reads an Elf{32,64}_Half.
int _readElfHalf(Reader reader) {
return _readElfBytes(reader, 2, 2);
}
int _readElfHalf(Reader reader) => _readElfBytes(reader, 2, 2);
// Reads an Elf{32,64}_Word.
int _readElfWord(Reader reader) {
return _readElfBytes(reader, 4, 4);
}
int _readElfWord(Reader reader) => _readElfBytes(reader, 4, 4);
// Reads an Elf64_Xword.
int _readElfXword(Reader reader) {
@ -50,9 +44,7 @@ int _readElfXword(Reader reader) {
}
// Reads an Elf{32,64}_Section.
int _readElfSection(Reader reader) {
return _readElfBytes(reader, 2, 2);
}
int _readElfSection(Reader reader) => _readElfBytes(reader, 2, 2);
// Used in cases where the value read for a given field is Elf32_Word on 32-bit
// and Elf64_Xword on 64-bit.

View file

@ -3,12 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'dart:typed_data';
import 'dart:math';
import 'dart:typed_data';
String paddedHex(int value, [int bytes = 0]) {
return value.toRadixString(16).padLeft(2 * bytes, '0');
}
String paddedHex(int value, [int bytes = 0]) =>
value.toRadixString(16).padLeft(2 * bytes, '0');
class Reader {
final ByteData bdata;