Skip to content

Commit 6670563

Browse files
DavidMina96Ali Abdelfattah
andauthored
[MOB-9457] Code Styling Enhancements (#268)
* Fix `omit_local_variable_types` * Remove unneeded await and generic for void calls Co-authored-by: Ali Abdelfattah <[email protected]>
1 parent dea2814 commit 6670563

13 files changed

+261
-281
lines changed

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ linter:
88
rules:
99
# Not necessary for our current APIs
1010
avoid_positional_boolean_parameters: false
11+
omit_local_variable_types: true

lib/src/models/crash_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CrashData {
1616
};
1717

1818
Map<String, dynamic> toMap() {
19-
final Map<String, dynamic> map = <String, dynamic>{};
19+
final map = <String, dynamic>{};
2020
map['message'] = message;
2121
map['os'] = os;
2222
map['platform'] = platform;

lib/src/models/exception_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExceptionData {
1515
};
1616

1717
Map<String, dynamic> toMap() {
18-
final Map<String, dynamic> map = <String, dynamic>{};
18+
final map = <String, dynamic>{};
1919
map['file'] = file;
2020
map['methodName'] = methodName;
2121
map['arguments'] = <dynamic>[];

lib/src/models/trace.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Trace {
88
: attributes = listOfAttributes ?? <String, dynamic>{};
99

1010
Map<String, dynamic> toMap() {
11-
final Map<String, dynamic> map = <String, dynamic>{};
11+
final map = <String, dynamic>{};
1212
map['id'] = id;
1313
map['name'] = name;
1414
map['attributes'] = attributes;

lib/src/modules/apm.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,29 @@ class APM {
2626
/// Enables or disables APM feature.
2727
/// [boolean] isEnabled
2828
static Future<void> setEnabled(bool isEnabled) async {
29-
final List<dynamic> params = <dynamic>[isEnabled];
30-
await _channel.invokeMethod<Object>('setAPMEnabled:', params);
29+
final params = <dynamic>[isEnabled];
30+
return _channel.invokeMethod('setAPMEnabled:', params);
3131
}
3232

3333
/// Sets log Level to determine level of details in a log
3434
/// [logLevel] Enum value to determine the level
3535
static Future<void> setLogLevel(LogLevel logLevel) async {
36-
final List<dynamic> params = <dynamic>[logLevel.toString()];
37-
await _channel.invokeMethod<Object>('setAPMLogLevel:', params);
36+
final params = <dynamic>[logLevel.toString()];
37+
return _channel.invokeMethod('setAPMLogLevel:', params);
3838
}
3939

4040
/// Enables or disables cold app launch tracking.
4141
/// [boolean] isEnabled
4242
static Future<void> setColdAppLaunchEnabled(bool isEnabled) async {
43-
final List<dynamic> params = <dynamic>[isEnabled];
44-
await _channel.invokeMethod<Object>('setColdAppLaunchEnabled:', params);
43+
final params = <dynamic>[isEnabled];
44+
return _channel.invokeMethod('setColdAppLaunchEnabled:', params);
4545
}
4646

4747
/// Starts an execution trace.
4848
/// [String] name of the trace.
4949
static Future<Trace> startExecutionTrace(String name) async {
50-
final DateTime id = IBGDateTime.instance.now();
51-
final List<dynamic> params = <dynamic>[name, id.toString()];
50+
final id = IBGDateTime.instance.now();
51+
final params = <dynamic>[name, id.toString()];
5252
final traceId =
5353
await _channel.invokeMethod<String?>('startExecutionTrace:id:', params);
5454

@@ -71,12 +71,12 @@ class APM {
7171
String key,
7272
String value,
7373
) async {
74-
final List<dynamic> params = <dynamic>[
74+
final params = <dynamic>[
7575
id,
7676
key,
7777
value,
7878
];
79-
await _channel.invokeMethod<Object>(
79+
return _channel.invokeMethod(
8080
'setExecutionTraceAttribute:key:value:',
8181
params,
8282
);
@@ -85,32 +85,32 @@ class APM {
8585
/// Ends an execution trace.
8686
/// [String] id of the trace.
8787
static Future<void> endExecutionTrace(String id) async {
88-
final List<dynamic> params = <dynamic>[id];
89-
await _channel.invokeMethod<Object>('endExecutionTrace:', params);
88+
final params = <dynamic>[id];
89+
return _channel.invokeMethod('endExecutionTrace:', params);
9090
}
9191

9292
/// Enables or disables auto UI tracing.
9393
/// [boolean] isEnabled
9494
static Future<void> setAutoUITraceEnabled(bool isEnabled) async {
95-
final List<dynamic> params = <dynamic>[isEnabled];
96-
await _channel.invokeMethod<Object>('setAutoUITraceEnabled:', params);
95+
final params = <dynamic>[isEnabled];
96+
return _channel.invokeMethod('setAutoUITraceEnabled:', params);
9797
}
9898

9999
/// Starts UI trace.
100100
/// [String] name
101101
static Future<void> startUITrace(String name) async {
102-
final List<dynamic> params = <dynamic>[name];
103-
await _channel.invokeMethod<Object>('startUITrace:', params);
102+
final params = <dynamic>[name];
103+
return _channel.invokeMethod('startUITrace:', params);
104104
}
105105

106106
/// Ends UI trace.
107107
static Future<void> endUITrace() async {
108-
await _channel.invokeMethod<Object>('endUITrace');
108+
return _channel.invokeMethod('endUITrace');
109109
}
110110

111111
/// Ends App Launch.
112112
static Future<void> endAppLaunch() async {
113-
await _channel.invokeMethod<Object>('endAppLaunch');
113+
return _channel.invokeMethod('endAppLaunch');
114114
}
115115

116116
static FutureOr<void> networkLogAndroid(NetworkData data) {

lib/src/modules/bug_reporting.dart

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class BugReporting {
7979
///Enables and disables manual invocation and prompt options for bug and feedback.
8080
/// [boolean] isEnabled
8181
static Future<void> setEnabled(bool isEnabled) async {
82-
final List<dynamic> params = <dynamic>[isEnabled];
83-
await _channel.invokeMethod<Object>('setBugReportingEnabled:', params);
82+
final params = <dynamic>[isEnabled];
83+
return _channel.invokeMethod('setBugReportingEnabled:', params);
8484
}
8585

8686
/// Sets a block of code to be executed just before the SDK's UI is presented.
@@ -92,7 +92,7 @@ class BugReporting {
9292
) async {
9393
_channel.setMethodCallHandler(_handleMethod);
9494
_onInvokeCallback = function;
95-
await _channel.invokeMethod<Object>('setOnInvokeCallback');
95+
return _channel.invokeMethod('setOnInvokeCallback');
9696
}
9797

9898
/// Sets a block of code to be executed just before the SDK's UI is presented.
@@ -104,7 +104,7 @@ class BugReporting {
104104
) async {
105105
_channel.setMethodCallHandler(_handleMethod);
106106
_onDismissCallback = function;
107-
await _channel.invokeMethod<Object>('setOnDismissCallback');
107+
return _channel.invokeMethod('setOnDismissCallback');
108108
}
109109

110110
/// Sets the events that invoke the feedback form.
@@ -117,7 +117,7 @@ class BugReporting {
117117
invocationEvents?.map((e) => e.toString()).toList(growable: false) ??
118118
[];
119119
final params = <dynamic>[invocationEventsStrings];
120-
await _channel.invokeMethod<Object>('setInvocationEvents:', params);
120+
return _channel.invokeMethod('setInvocationEvents:', params);
121121
}
122122

123123
/// Sets whether attachments in bug reporting and in-app messaging are enabled or not.
@@ -133,13 +133,13 @@ class BugReporting {
133133
bool galleryImage,
134134
bool screenRecording,
135135
) async {
136-
final List<dynamic> params = <dynamic>[
136+
final params = <dynamic>[
137137
screenshot,
138138
extraScreenshot,
139139
galleryImage,
140140
screenRecording
141141
];
142-
await _channel.invokeMethod<Object>(
142+
return _channel.invokeMethod(
143143
'setEnabledAttachmentTypes:extraScreenShot:galleryImage:screenRecording:',
144144
params,
145145
);
@@ -151,7 +151,7 @@ class BugReporting {
151151
final reportTypesStrings =
152152
reportTypes?.map((e) => e.toString()).toList(growable: false) ?? [];
153153
final params = <dynamic>[reportTypesStrings];
154-
await _channel.invokeMethod<Object>('setReportTypes:', params);
154+
return _channel.invokeMethod('setReportTypes:', params);
155155
}
156156

157157
/// Sets whether the extended bug report mode should be disabled, enabled with
@@ -160,8 +160,8 @@ class BugReporting {
160160
static Future<void> setExtendedBugReportMode(
161161
ExtendedBugReportMode extendedBugReportMode,
162162
) async {
163-
final List<dynamic> params = <dynamic>[extendedBugReportMode.toString()];
164-
await _channel.invokeMethod<Object>('setExtendedBugReportMode:', params);
163+
final params = <dynamic>[extendedBugReportMode.toString()];
164+
return _channel.invokeMethod('setExtendedBugReportMode:', params);
165165
}
166166

167167
/// Sets the invocation options.
@@ -174,7 +174,7 @@ class BugReporting {
174174
invocationOptions?.map((e) => e.toString()).toList(growable: false) ??
175175
[];
176176
final params = <dynamic>[invocationOptionsStrings];
177-
await _channel.invokeMethod<Object>('setInvocationOptions:', params);
177+
return _channel.invokeMethod('setInvocationOptions:', params);
178178
}
179179

180180
/// Sets the floating button position.
@@ -184,11 +184,8 @@ class BugReporting {
184184
FloatingButtonEdge floatingButtonEdge,
185185
int offsetFromTop,
186186
) async {
187-
final List<dynamic> params = <dynamic>[
188-
floatingButtonEdge.toString(),
189-
offsetFromTop
190-
];
191-
await _channel.invokeMethod<Object>(
187+
final params = <dynamic>[floatingButtonEdge.toString(), offsetFromTop];
188+
return _channel.invokeMethod(
192189
'setFloatingButtonEdge:withTopOffset:',
193190
params,
194191
);
@@ -204,11 +201,8 @@ class BugReporting {
204201
final invocationOptionsStrings =
205202
invocationOptions?.map((e) => e.toString()).toList(growable: false) ??
206203
[];
207-
final List<dynamic> params = <dynamic>[
208-
reportType.toString(),
209-
invocationOptionsStrings
210-
];
211-
await _channel.invokeMethod<Object>(
204+
final params = <dynamic>[reportType.toString(), invocationOptionsStrings];
205+
return _channel.invokeMethod(
212206
'showBugReportingWithReportTypeAndOptions:options:',
213207
params,
214208
);
@@ -221,8 +215,8 @@ class BugReporting {
221215
double iPhoneShakingThreshold,
222216
) async {
223217
if (IBGBuildInfo.instance.isIOS) {
224-
final List<dynamic> params = <dynamic>[iPhoneShakingThreshold];
225-
await _channel.invokeMethod<Object>(
218+
final params = <dynamic>[iPhoneShakingThreshold];
219+
return _channel.invokeMethod(
226220
'setShakingThresholdForiPhone:',
227221
params,
228222
);
@@ -236,8 +230,8 @@ class BugReporting {
236230
double iPadShakingThreshold,
237231
) async {
238232
if (IBGBuildInfo.instance.isIOS) {
239-
final List<dynamic> params = <dynamic>[iPadShakingThreshold];
240-
await _channel.invokeMethod<Object>(
233+
final params = <dynamic>[iPadShakingThreshold];
234+
return _channel.invokeMethod(
241235
'setShakingThresholdForiPad:',
242236
params,
243237
);
@@ -253,8 +247,8 @@ class BugReporting {
253247
int androidThreshold,
254248
) async {
255249
if (IBGBuildInfo.instance.isAndroid) {
256-
final List<dynamic> params = <dynamic>[androidThreshold];
257-
await _channel.invokeMethod<Object>(
250+
final params = <dynamic>[androidThreshold];
251+
return _channel.invokeMethod(
258252
'setShakingThresholdForAndroid:',
259253
params,
260254
);

lib/src/modules/crash_reporting.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class CrashReporting {
2020
/// [boolean] isEnabled
2121
static Future<void> setEnabled(bool isEnabled) async {
2222
enabled = isEnabled;
23-
final List<dynamic> params = <dynamic>[isEnabled];
24-
await _channel.invokeMethod<Object>('setCrashReportingEnabled:', params);
23+
final params = <dynamic>[isEnabled];
24+
return _channel.invokeMethod('setCrashReportingEnabled:', params);
2525
}
2626

2727
static Future<void> reportCrash(Object exception, StackTrace stack) async {
@@ -56,9 +56,9 @@ class CrashReporting {
5656
StackTrace stack,
5757
bool handled,
5858
) async {
59-
final Trace trace = Trace.from(stack);
60-
final List<ExceptionData> frames = <ExceptionData>[];
61-
for (int i = 0; i < trace.frames.length; i++) {
59+
final trace = Trace.from(stack);
60+
final frames = <ExceptionData>[];
61+
for (var i = 0; i < trace.frames.length; i++) {
6262
frames.add(
6363
ExceptionData(
6464
trace.frames[i].uri.toString(),
@@ -68,13 +68,13 @@ class CrashReporting {
6868
),
6969
);
7070
}
71-
final CrashData crashData = CrashData(
71+
final crashData = CrashData(
7272
exception.toString(),
7373
IBGBuildInfo.instance.operatingSystem,
7474
frames,
7575
);
76-
final List<dynamic> params = <dynamic>[jsonEncode(crashData), handled];
77-
await _channel.invokeMethod<Object>(
76+
final params = <dynamic>[jsonEncode(crashData), handled];
77+
return _channel.invokeMethod(
7878
'sendJSCrashByReflection:handled:',
7979
params,
8080
);

lib/src/modules/feature_requests.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FeatureRequests {
1414

1515
///Shows the UI for feature requests list
1616
static Future<void> show() async {
17-
await _channel.invokeMethod<Object>('showFeatureRequests');
17+
return _channel.invokeMethod('showFeatureRequests');
1818
}
1919

2020
/// Sets whether users are required to enter an email address or not when sending reports.
@@ -29,7 +29,7 @@ class FeatureRequests {
2929
final actionTypesStrings =
3030
actionTypes?.map((e) => e.toString()).toList(growable: false) ?? [];
3131
final params = <dynamic>[isEmailFieldRequired, actionTypesStrings];
32-
await _channel.invokeMethod<Object>(
32+
return _channel.invokeMethod(
3333
'setEmailFieldRequiredForFeatureRequests:forAction:',
3434
params,
3535
);

0 commit comments

Comments
 (0)