Skip to content

Commit bcdefdc

Browse files
zoechiyjbanov
authored andcommitted
minor cleanup (#7)
1 parent b5dcb6b commit bcdefdc

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

lib/sentry.dart

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SentryClient {
2929
/// The default logger name used if no other value is supplied.
3030
static const String defaultLoggerName = 'SentryClient';
3131

32-
/// Instantiates a client using [dns] issued to your project by Sentry.io as
32+
/// Instantiates a client using [dsn] issued to your project by Sentry.io as
3333
/// the endpoint for submitting events.
3434
///
3535
/// [environmentAttributes] contain event attributes that do not change over
@@ -161,7 +161,7 @@ class SentryClient {
161161
'sentry_secret=$secretKey',
162162
};
163163

164-
Map<String, dynamic> json = <String, dynamic>{
164+
final Map<String, dynamic> json = <String, dynamic>{
165165
'project': projectId,
166166
'event_id': _uuidGenerator(),
167167
'timestamp': formatDateAsIso8601WithSecondPrecision(_clock.now()),
@@ -221,15 +221,13 @@ class SentryClient {
221221
/// contain the description of the error.
222222
@immutable
223223
class SentryResponse {
224-
SentryResponse.success({@required eventId})
224+
const SentryResponse.success({@required this.eventId})
225225
: isSuccessful = true,
226-
eventId = eventId,
227226
error = null;
228227

229-
SentryResponse.failure(error)
228+
const SentryResponse.failure(this.error)
230229
: isSuccessful = false,
231-
eventId = null,
232-
error = error;
230+
eventId = null;
233231

234232
/// Whether event was submitted successfully.
235233
final bool isSuccessful;
@@ -243,9 +241,8 @@ class SentryResponse {
243241

244242
typedef UuidGenerator = String Function();
245243

246-
String _generateUuidV4WithoutDashes() {
247-
return new Uuid().generateV4().replaceAll('-', '');
248-
}
244+
String _generateUuidV4WithoutDashes() =>
245+
new Uuid().generateV4().replaceAll('-', '');
249246

250247
/// Severity of the logged [Event].
251248
@immutable
@@ -276,7 +273,7 @@ class Event {
276273
static const String defaultFingerprint = '{{ default }}';
277274

278275
/// Creates an event.
279-
Event({
276+
const Event({
280277
this.loggerName,
281278
this.serverName,
282279
this.release,

lib/src/stack_trace.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Map<String, dynamic> asynchronousGapFrameJson = const <String, dynamic>{
1010
'abs_path': '<asynchronous suspension>',
1111
};
1212

13-
/// Encodes [strackTrace] as JSON in the Sentry.io format.
13+
/// Encodes [stackTrace] as JSON in the Sentry.io format.
1414
///
1515
/// [stackTrace] must be [String] or [StackTrace].
1616
List<Map<String, dynamic>> encodeStackTrace(dynamic stackTrace) {

lib/src/utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void mergeAttributes(Map<String, dynamic> attributes,
1212
{@required Map<String, dynamic> into}) {
1313
assert(attributes != null && into != null);
1414
attributes.forEach((String name, dynamic value) {
15-
dynamic targetValue = into[name];
15+
final dynamic targetValue = into[name];
1616
if (value is Map && targetValue is Map) {
1717
mergeAttributes(value, into: targetValue);
1818
} else {

test/sentry_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void main() {
4646
clock: fakeClock,
4747
uuidGenerator: () => 'X' * 32,
4848
compressPayload: compressPayload,
49-
environmentAttributes: new Event(
49+
environmentAttributes: const Event(
5050
serverName: 'test.server.com',
5151
release: '1.2.3',
5252
environment: 'staging',
@@ -65,7 +65,7 @@ void main() {
6565

6666
expect(postUri, client.postUri);
6767

68-
Map<String, String> expectedHeaders = <String, String>{
68+
final Map<String, String> expectedHeaders = <String, String>{
6969
'User-Agent': '$sdkName/$sdkVersion',
7070
'Content-Type': 'application/json',
7171
'X-Sentry-Auth': 'Sentry sentry_version=6, '
@@ -86,7 +86,7 @@ void main() {
8686
json = JSON.decode(UTF8.decode(body));
8787
}
8888
final Map<String, dynamic> stacktrace = json.remove('stacktrace');
89-
expect(stacktrace['frames'], new isInstanceOf<List>());
89+
expect(stacktrace['frames'], const isInstanceOf<List>());
9090
expect(stacktrace['frames'], isNotEmpty);
9191

9292
final Map<String, dynamic> topFrame = stacktrace['frames'].first;
@@ -141,7 +141,7 @@ void main() {
141141
clock: fakeClock,
142142
uuidGenerator: () => 'X' * 32,
143143
compressPayload: false,
144-
environmentAttributes: new Event(
144+
environmentAttributes: const Event(
145145
serverName: 'test.server.com',
146146
release: '1.2.3',
147147
environment: 'staging',

0 commit comments

Comments
 (0)