Skip to content

Commit daff603

Browse files
committed
Fixes from code metrics lints
1 parent 75b3f91 commit daff603

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+325
-456
lines changed

packages/devtools_app/lib/src/charts/flame_chart.dart

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,7 @@ abstract class FlameChartState<T extends FlameChart,
379379
}
380380

381381
void _handleKeyEvent(RawKeyEvent event) {
382-
if (event.isAltPressed) {
383-
_altKeyPressed = true;
384-
} else {
385-
_altKeyPressed = false;
386-
}
382+
_altKeyPressed = event.isAltPressed ? true : false;
387383

388384
// Only handle down events so logic is not duplicated on key up.
389385
if (event is RawKeyDownEvent) {
@@ -1120,15 +1116,13 @@ class FlameChartNode<T extends FlameChartDataMixin<T>> {
11201116
)
11211117
: const SizedBox(),
11221118
);
1123-
if (hovered || !selectable) {
1124-
return DevToolsTooltip(
1125-
key: key,
1126-
message: data.tooltip,
1127-
child: node,
1128-
);
1129-
} else {
1130-
return node;
1131-
}
1119+
return (hovered || !selectable)
1120+
? DevToolsTooltip(
1121+
key: key,
1122+
message: data.tooltip,
1123+
child: node,
1124+
)
1125+
: node;
11321126
}
11331127

11341128
Color _backgroundColor({
@@ -1366,12 +1360,9 @@ class TimelineGridPainter extends FlameChartPainter {
13661360
final microsPerInterval = _microsPerInterval(intervalWidth);
13671361
int timestampMicros = _startingTimestamp(intervalWidth, microsPerInterval);
13681362
double lineX;
1369-
if (visible.left <= chartStartInset) {
1370-
lineX = chartStartInset - visible.left;
1371-
} else {
1372-
lineX =
1373-
intervalWidth - ((visible.left - chartStartInset) % intervalWidth);
1374-
}
1363+
lineX = visible.left <= chartStartInset
1364+
? chartStartInset - visible.left
1365+
: intervalWidth - ((visible.left - chartStartInset) % intervalWidth);
13751366

13761367
while (lineX < constraints.maxWidth) {
13771368
_paintTimestamp(canvas, timestampMicros, intervalWidth, lineX);

packages/devtools_app/lib/src/charts/treemap.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,7 @@ class TreemapNode extends TreeNode<TreemapNode> {
609609
if (!showDiff) {
610610
return backgroundColor ?? mainUiColor;
611611
}
612-
if (byteSize < 0) {
613-
return treemapDecreaseColor;
614-
} else {
615-
return treemapIncreaseColor;
616-
}
612+
return byteSize < 0 ? treemapDecreaseColor : treemapIncreaseColor;
617613
}
618614

619615
TextSpan displayText({Color? color, bool oneLine = true}) {

packages/devtools_app/lib/src/framework/status_line.dart

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,27 @@ class StatusLine extends StatelessWidget {
9898
MediaSize screenWidth,
9999
) {
100100
final String? docPageId = currentScreen.docPageId;
101-
if (docPageId != null) {
102-
return RichText(
103-
text: LinkTextSpan(
104-
link: Link(
105-
display: screenWidth <= MediaSize.xs
106-
? docPageId
107-
: 'flutter.dev/devtools/$docPageId',
108-
url: 'https://flutter.dev/devtools/$docPageId',
109-
gaScreenName: currentScreen.screenId,
110-
gaSelectedItemDescription: analytics_constants.documentationLink,
111-
),
112-
context: context,
113-
),
114-
);
115-
} else {
116-
// Use a placeholder for pages with no explicit documentation.
117-
return Flexible(
118-
child: Text(
119-
'${screenWidth <= MediaSize.xs ? '' : 'DevTools '}${devtools.version}',
120-
overflow: TextOverflow.ellipsis,
121-
),
122-
);
123-
}
101+
return docPageId != null
102+
? RichText(
103+
text: LinkTextSpan(
104+
link: Link(
105+
display: screenWidth <= MediaSize.xs
106+
? docPageId
107+
: 'flutter.dev/devtools/$docPageId',
108+
url: 'https://flutter.dev/devtools/$docPageId',
109+
gaScreenName: currentScreen.screenId,
110+
gaSelectedItemDescription:
111+
analytics_constants.documentationLink,
112+
),
113+
context: context,
114+
),
115+
)
116+
: Flexible(
117+
child: Text(
118+
'${screenWidth <= MediaSize.xs ? '' : 'DevTools '}${devtools.version}',
119+
overflow: TextOverflow.ellipsis,
120+
),
121+
);
124122
}
125123

126124
Widget buildConnectionStatus(BuildContext context, MediaSize screenWidth) {

packages/devtools_app/lib/src/http/_http_date.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ class HttpDate {
221221

222222
int expectNum(String separator) {
223223
int pos;
224-
if (separator.length > 0) {
225-
pos = date.indexOf(separator, index);
226-
} else {
227-
pos = date.length;
228-
}
224+
pos = separator.length > 0 ? date.indexOf(separator, index) : date.length;
229225
String tmp = date.substring(index, pos);
230226
index = pos + separator.length;
231227
try {

packages/devtools_app/lib/src/primitives/message_bus.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ class MessageBus {
2828
/// Listen for events on the event bus. Clients can pass in an optional [type],
2929
/// which filters the events to only those specific ones.
3030
Stream<BusEvent> onEvent({String? type}) {
31-
if (type == null) {
32-
return _controller.stream;
33-
} else {
34-
return _controller.stream.where((BusEvent event) => event.type == type);
35-
}
31+
return type == null
32+
? _controller.stream
33+
: _controller.stream.where((BusEvent event) => event.type == type);
3634
}
3735

3836
/// Add an event to the event bus.

packages/devtools_app/lib/src/primitives/utils.dart

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ String msText(
152152
/// Render the given [Duration] to text using either seconds or milliseconds as
153153
/// the units, depending on the value of the duration.
154154
String renderDuration(Duration duration) {
155-
if (duration.inMilliseconds < 1000) {
156-
return '${nf.format(duration.inMilliseconds)}ms';
157-
} else {
158-
return '${(duration.inMilliseconds / 1000).toStringAsFixed(1)}s';
159-
}
155+
return duration.inMilliseconds < 1000
156+
? '${nf.format(duration.inMilliseconds)}ms'
157+
: '${(duration.inMilliseconds / 1000).toStringAsFixed(1)}s';
160158
}
161159

162160
T? nullSafeMin<T extends num>(T? a, T? b) {
@@ -1046,7 +1044,7 @@ final _lowercaseLookup = <String, String>{};
10461044
extension StringExtension on String {
10471045
bool caseInsensitiveContains(Pattern? pattern) {
10481046
if (pattern is RegExp) {
1049-
assert(pattern.isCaseSensitive == false);
1047+
assert(!pattern.isCaseSensitive);
10501048
return contains(pattern);
10511049
} else if (pattern is String) {
10521050
final lowerCase = _lowercaseLookup.putIfAbsent(this, () => toLowerCase());
@@ -1181,11 +1179,9 @@ Uri? getServiceUriFromQueryString(String? location) {
11811179
final token = queryParams['token'];
11821180
final host = queryParams['host'] ?? 'localhost';
11831181
if (port != null) {
1184-
if (token == null) {
1185-
return Uri.parse('ws://$host:$port/ws');
1186-
} else {
1187-
return Uri.parse('ws://$host:$port/$token/ws');
1188-
}
1182+
return token == null
1183+
? Uri.parse('ws://$host:$port/ws')
1184+
: Uri.parse('ws://$host:$port/$token/ws');
11891185
}
11901186

11911187
return null;

packages/devtools_app/lib/src/screens/app_size/app_size_controller.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -695,16 +695,14 @@ class AppSizeController {
695695
}
696696

697697
// If none of the children matched the diff tree type
698-
if (totalByteSize == 0 && skipNodesWithNoByteSizeChange) {
699-
return null;
700-
} else {
701-
return _buildNode(
702-
treeJson,
703-
totalByteSize,
704-
children: treemapNodeChildren,
705-
showDiff: showDiff,
706-
);
707-
}
698+
return totalByteSize == 0 && skipNodesWithNoByteSizeChange
699+
? null
700+
: _buildNode(
701+
treeJson,
702+
totalByteSize,
703+
children: treemapNodeChildren,
704+
showDiff: showDiff,
705+
);
708706
}
709707

710708
TreemapNode _buildNode(

packages/devtools_app/lib/src/screens/app_size/app_size_table.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,7 @@ class _DiffColumn extends ColumnData<TreemapNode> {
239239

240240
@override
241241
Color getTextColor(TreemapNode dataObject) {
242-
if (dataObject.byteSize < 0) {
243-
return tableDecreaseColor;
244-
} else {
245-
return tableIncreaseColor;
246-
}
242+
return dataObject.byteSize < 0 ? tableDecreaseColor : tableIncreaseColor;
247243
}
248244
}
249245

packages/devtools_app/lib/src/screens/debugger/call_stack.dart

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -63,40 +63,42 @@ class _CallStackState extends State<CallStack>
6363
final frameDescription = frame.description;
6464
final locationDescription = frame.location;
6565

66-
if (asyncMarker) {
67-
child = Row(
68-
children: [
69-
const SizedBox(width: defaultSpacing, child: Divider()),
70-
Padding(
71-
padding: const EdgeInsets.symmetric(horizontal: densePadding),
72-
child: Text(
73-
frameDescription,
74-
style: selected ? theme.selectedTextStyle : theme.subtleTextStyle,
66+
child = asyncMarker
67+
? Row(
68+
children: [
69+
const SizedBox(width: defaultSpacing, child: Divider()),
70+
Padding(
71+
padding: const EdgeInsets.symmetric(horizontal: densePadding),
72+
child: Text(
73+
frameDescription,
74+
style: selected
75+
? theme.selectedTextStyle
76+
: theme.subtleTextStyle,
77+
),
78+
),
79+
const Expanded(child: Divider())
80+
],
81+
)
82+
: RichText(
83+
maxLines: 1,
84+
overflow: TextOverflow.ellipsis,
85+
text: TextSpan(
86+
text: frameDescription,
87+
style: selected
88+
? theme.selectedTextStyle
89+
: (asyncFrame || noLineInfo
90+
? theme.subtleTextStyle
91+
: theme.regularTextStyle),
92+
children: [
93+
TextSpan(
94+
text: ' $locationDescription',
95+
style: selected
96+
? theme.selectedTextStyle
97+
: theme.subtleTextStyle,
98+
)
99+
],
75100
),
76-
),
77-
const Expanded(child: Divider()),
78-
],
79-
);
80-
} else {
81-
child = RichText(
82-
maxLines: 1,
83-
overflow: TextOverflow.ellipsis,
84-
text: TextSpan(
85-
text: frameDescription,
86-
style: selected
87-
? theme.selectedTextStyle
88-
: (asyncFrame || noLineInfo
89-
? theme.subtleTextStyle
90-
: theme.regularTextStyle),
91-
children: [
92-
TextSpan(
93-
text: ' $locationDescription',
94-
style: selected ? theme.selectedTextStyle : theme.subtleTextStyle,
95-
),
96-
],
97-
),
98-
);
99-
}
101+
);
100102

101103
final isAsyncBreak = frame.frame.kind == FrameKind.kAsyncSuspensionMarker;
102104

@@ -112,17 +114,15 @@ class _CallStackState extends State<CallStack>
112114
),
113115
);
114116

115-
if (isAsyncBreak) {
116-
return result;
117-
} else {
118-
return DevToolsTooltip(
119-
message: locationDescription == null
120-
? frameDescription
121-
: '$frameDescription $locationDescription',
122-
waitDuration: tooltipWaitLong,
123-
child: result,
124-
);
125-
}
117+
return isAsyncBreak
118+
? result
119+
: DevToolsTooltip(
120+
message: locationDescription == null
121+
? frameDescription
122+
: '$frameDescription $locationDescription',
123+
waitDuration: tooltipWaitLong,
124+
child: result,
125+
);
126126
}
127127

128128
Future<void> _onStackFrameSelected(StackFrameAndSourcePosition frame) async {

packages/devtools_app/lib/src/screens/debugger/debugger_controller.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,8 @@ class DebuggerController extends DisposableController
627627
void selectStackFrame(StackFrameAndSourcePosition? frame) {
628628
_selectedStackFrame.value = frame;
629629

630-
if (frame != null) {
631-
_variables.value = _createVariablesForFrame(frame.frame);
632-
} else {
633-
_variables.value = [];
634-
}
630+
_variables.value =
631+
frame != null ? _createVariablesForFrame(frame.frame) : [];
635632

636633
final scriptRef = frame?.scriptRef;
637634
final position = frame?.position;

0 commit comments

Comments
 (0)