diff --git a/pkg/native_stack_traces/analysis_options.yaml b/pkg/native_stack_traces/analysis_options.yaml index 572dd239d09..d0f68fe9980 100644 --- a/pkg/native_stack_traces/analysis_options.yaml +++ b/pkg/native_stack_traces/analysis_options.yaml @@ -1 +1,8 @@ include: package:lints/recommended.yaml + +linter: + rules: + - avoid_dynamic_calls + - directives_ordering + - prefer_expression_function_bodies + - sort_pub_dependencies diff --git a/pkg/native_stack_traces/bin/decode.dart b/pkg/native_stack_traces/bin/decode.dart index f1302d7fb16..a7ca956d427 100644 --- a/pkg/native_stack_traces/bin/decode.dart +++ b/pkg/native_stack_traces/bin/decode.dart @@ -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 = []; - for (final String s in options['location'] + options.rest) { + for (final String s in [ + ...(options['location'] as List), + ...options.rest, + ]) { final location = convertAddress(header, s); if (location == null) return usageError('could not parse PC address $s'); locations.add(location); diff --git a/pkg/native_stack_traces/lib/elf.dart b/pkg/native_stack_traces/lib/elf.dart index 33166553981..31272b134f8 100644 --- a/pkg/native_stack_traces/lib/elf.dart +++ b/pkg/native_stack_traces/lib/elf.dart @@ -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; diff --git a/pkg/native_stack_traces/lib/src/dwarf.dart b/pkg/native_stack_traces/lib/src/dwarf.dart index e521d0e79f0..06ace824c1d 100644 --- a/pkg/native_stack_traces/lib/src/dwarf.dart +++ b/pkg/native_stack_traces/lib/src/dwarf.dart @@ -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)'; diff --git a/pkg/native_stack_traces/lib/src/elf.dart b/pkg/native_stack_traces/lib/src/elf.dart index c3375fa2fb9..ac7cb502d7b 100644 --- a/pkg/native_stack_traces/lib/src/elf.dart +++ b/pkg/native_stack_traces/lib/src/elf.dart @@ -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. diff --git a/pkg/native_stack_traces/lib/src/reader.dart b/pkg/native_stack_traces/lib/src/reader.dart index 02accbfa5e3..815887878ae 100644 --- a/pkg/native_stack_traces/lib/src/reader.dart +++ b/pkg/native_stack_traces/lib/src/reader.dart @@ -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;