Run dartfmt --fix (#134)
Drop optional new.
diff --git a/example/example.dart b/example/example.dart
index 06578c3..7bc2b4b 100644
--- a/example/example.dart
+++ b/example/example.dart
@@ -24,7 +24,7 @@
Analytics getAnalytics() {
if (_analytics == null || _lastUa != _ua()) {
_lastUa = _ua();
- _analytics = new AnalyticsHtml(_lastUa, 'Test app', '1.0');
+ _analytics = AnalyticsHtml(_lastUa, 'Test app', '1.0');
_analytics.sendScreenView(window.location.pathname);
}
diff --git a/example/ga.dart b/example/ga.dart
index 3df1573..239dfd0 100644
--- a/example/ga.dart
+++ b/example/ga.dart
@@ -19,7 +19,7 @@
String ua = args.isEmpty ? defaultUA : args.first;
- Analytics ga = new AnalyticsIO(ua, 'ga_test', '3.0');
+ Analytics ga = AnalyticsIO(ua, 'ga_test', '3.0');
await ga.sendScreenView('home');
await ga.sendScreenView('files');
diff --git a/lib/src/usage_impl.dart b/lib/src/usage_impl.dart
index 7a8cf21..dfc3bcb 100644
--- a/lib/src/usage_impl.dart
+++ b/lib/src/usage_impl.dart
@@ -29,7 +29,7 @@
ThrottlingBucket(this.startingCount) {
drops = startingCount;
- _lastReplenish = new DateTime.now().millisecondsSinceEpoch;
+ _lastReplenish = DateTime.now().millisecondsSinceEpoch;
}
bool removeDrop() {
@@ -44,7 +44,7 @@
}
void _checkReplenish() {
- int now = new DateTime.now().millisecondsSinceEpoch;
+ int now = DateTime.now().millisecondsSinceEpoch;
if (_lastReplenish + 1000 >= now) {
int inc = (now - _lastReplenish) ~/ 1000;
@@ -68,7 +68,7 @@
final PersistentProperties properties;
final PostHandler postHandler;
- final ThrottlingBucket _bucket = new ThrottlingBucket(20);
+ final ThrottlingBucket _bucket = ThrottlingBucket(20);
final Map<String, dynamic> _variableMap = {};
final List<Future> _futures = [];
@@ -79,7 +79,7 @@
String _url;
final StreamController<Map<String, dynamic>> _sendController =
- new StreamController.broadcast(sync: true);
+ StreamController.broadcast(sync: true);
AnalyticsImpl(this.trackingId, this.properties, this.postHandler,
{this.applicationName, this.applicationVersion, String analyticsUrl}) {
@@ -158,8 +158,7 @@
@override
AnalyticsTimer startTimer(String variableName,
{String category, String label}) {
- return new AnalyticsTimer(this, variableName,
- category: category, label: label);
+ return AnalyticsTimer(this, variableName, category: category, label: label);
}
@override
@@ -216,7 +215,7 @@
void close() => postHandler.close();
@override
- String get clientId => properties['clientId'] ??= new Uuid().generateV4();
+ String get clientId => properties['clientId'] ??= Uuid().generateV4();
/// Send raw data to analytics. Callers should generally use one of the typed
/// methods (`sendScreenView`, `sendEvent`, ...).
@@ -230,7 +229,7 @@
/// Valid values for [hitType] are: 'pageview', 'screenview', 'event',
/// 'transaction', 'item', 'social', 'exception', and 'timing'.
Future _sendPayload(String hitType, Map<String, dynamic> args) {
- if (!enabled) return new Future.value();
+ if (!enabled) return Future.value();
if (_bucket.removeDrop()) {
_variableMap.forEach((key, value) {
@@ -246,7 +245,7 @@
return _recordFuture(postHandler.sendPost(_url, args));
} else {
- return new Future.value();
+ return Future.value();
}
}
diff --git a/lib/src/usage_impl_html.dart b/lib/src/usage_impl_html.dart
index 010b508..25b74c7 100644
--- a/lib/src/usage_impl_html.dart
+++ b/lib/src/usage_impl_html.dart
@@ -16,8 +16,8 @@
AnalyticsHtml(
String trackingId, String applicationName, String applicationVersion,
{String analyticsUrl})
- : super(trackingId, new HtmlPersistentProperties(applicationName),
- new HtmlPostHandler(),
+ : super(trackingId, HtmlPersistentProperties(applicationName),
+ HtmlPostHandler(),
applicationName: applicationName,
applicationVersion: applicationVersion,
analyticsUrl: analyticsUrl) {
@@ -30,8 +30,8 @@
}
}
-typedef Future<HttpRequest> HttpRequestor(String url,
- {String method, sendData});
+typedef HttpRequestor = Future<HttpRequest> Function(String url,
+ {String method, dynamic sendData});
class HtmlPostHandler extends PostHandler {
final HttpRequestor mockRequestor;
diff --git a/lib/src/usage_impl_io.dart b/lib/src/usage_impl_io.dart
index 53aa967..29f673c 100644
--- a/lib/src/usage_impl_io.dart
+++ b/lib/src/usage_impl_io.dart
@@ -27,9 +27,9 @@
{String analyticsUrl, Directory documentDirectory})
: super(
trackingId,
- new IOPersistentProperties(applicationName,
+ IOPersistentProperties(applicationName,
documentDirPath: documentDirectory?.path),
- new IOPostHandler(),
+ IOPostHandler(),
applicationName: applicationName,
applicationVersion: applicationVersion,
analyticsUrl: analyticsUrl) {
@@ -86,7 +86,7 @@
String data = postEncode(parameters);
if (_client == null) {
- _client = mockClient != null ? mockClient : new HttpClient();
+ _client = mockClient != null ? mockClient : HttpClient();
_client.userAgent = _userAgent;
}
@@ -105,7 +105,7 @@
void close() => _client?.close();
}
-JsonEncoder _jsonEncoder = new JsonEncoder.withIndent(' ');
+JsonEncoder _jsonEncoder = JsonEncoder.withIndent(' ');
class IOPersistentProperties extends PersistentProperties {
File _file;
@@ -114,7 +114,7 @@
IOPersistentProperties(String name, {String documentDirPath}) : super(name) {
String fileName = '.${name.replaceAll(' ', '_')}';
documentDirPath ??= userHomeDir();
- _file = new File(path.join(documentDirPath, fileName));
+ _file = File(path.join(documentDirPath, fileName));
if (!_file.existsSync()) {
_file.createSync();
}
diff --git a/lib/usage.dart b/lib/usage.dart
index 0622335..0c84c16 100644
--- a/lib/usage.dart
+++ b/lib/usage.dart
@@ -25,10 +25,10 @@
import 'dart:async';
// Matches file:/, non-ws, /, non-ws, .dart
-final RegExp _pathRegex = new RegExp(r'file:/\S+/(\S+\.dart)');
+final RegExp _pathRegex = RegExp(r'file:/\S+/(\S+\.dart)');
// Match multiple tabs or spaces.
-final RegExp _tabOrSpaceRegex = new RegExp(r'[\t ]+');
+final RegExp _tabOrSpaceRegex = RegExp(r'[\t ]+');
/// An interface to a Google Analytics session.
///
@@ -165,12 +165,12 @@
AnalyticsTimer(this.analytics, this.variableName,
{this.category, this.label}) {
- _startMillis = new DateTime.now().millisecondsSinceEpoch;
+ _startMillis = DateTime.now().millisecondsSinceEpoch;
}
int get currentElapsedMillis {
if (_endMillis == null) {
- return new DateTime.now().millisecondsSinceEpoch - _startMillis;
+ return DateTime.now().millisecondsSinceEpoch - _startMillis;
} else {
return _endMillis - _startMillis;
}
@@ -179,9 +179,9 @@
/// Finish the timer, calculate the elapsed time, and send the information to
/// analytics. Once this is called, any future invocations are no-ops.
Future finish() {
- if (_endMillis != null) return new Future.value();
+ if (_endMillis != null) return Future.value();
- _endMillis = new DateTime.now().millisecondsSinceEpoch;
+ _endMillis = DateTime.now().millisecondsSinceEpoch;
return analytics.sendTiming(variableName, currentElapsedMillis,
category: category, label: label);
}
@@ -201,7 +201,7 @@
/// Events are never added to this controller for the mock implementation.
final StreamController<Map<String, dynamic>> _sendController =
- new StreamController.broadcast();
+ StreamController.broadcast();
/// Create a new [AnalyticsMock]. If [logCalls] is true, all calls will be
/// logged to stdout.
@@ -254,8 +254,7 @@
@override
AnalyticsTimer startTimer(String variableName,
{String category, String label}) {
- return new AnalyticsTimer(this, variableName,
- category: category, label: label);
+ return AnalyticsTimer(this, variableName, category: category, label: label);
}
@override
@@ -272,7 +271,7 @@
Stream<Map<String, dynamic>> get onSend => _sendController.stream;
@override
- Future waitForLastPing({Duration timeout}) => new Future.value();
+ Future waitForLastPing({Duration timeout}) => Future.value();
@override
void close() {}
@@ -282,7 +281,7 @@
print('analytics: ${hitType} ${m}');
}
- return new Future.value();
+ return Future.value();
}
}
@@ -294,7 +293,7 @@
/// of the stacktrace. GA has a 100 char limit on the text that can be sent for
/// an exception. This will try and make those first 100 chars contain
/// information useful to debugging the issue.
-String sanitizeStacktrace(dynamic st, {bool shorten: true}) {
+String sanitizeStacktrace(dynamic st, {bool shorten = true}) {
String str = '${st}';
Iterable<Match> iter = _pathRegex.allMatches(str);
diff --git a/lib/uuid/uuid.dart b/lib/uuid/uuid.dart
index eaafeb2..a424d93 100644
--- a/lib/uuid/uuid.dart
+++ b/lib/uuid/uuid.dart
@@ -17,7 +17,7 @@
/// For more information, see
/// [en.wikipedia.org/wiki/Universally_unique_identifier](http://en.wikipedia.org/wiki/Universally_unique_identifier).
class Uuid {
- final Random _random = new Random();
+ final Random _random = Random();
/// Generate a version 4 (random) uuid. This is a uuid scheme that only uses
/// random numbers as the source of the generated uuid.
@@ -28,7 +28,7 @@
return '${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}-'
'${_bitsDigits(16, 4)}-'
'4${_bitsDigits(12, 3)}-'
- '${_printDigits(special, 1)}${_bitsDigits(12, 3)}-'
+ '${_printDigits(special, 1)}${_bitsDigits(12, 3)}-'
'${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}';
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 7a07707..fa7f5d6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -3,7 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
name: usage
-version: 3.4.1
+version: 3.4.2-dev
description: A Google Analytics wrapper for both command-line, web, and Flutter apps.
homepage: https://github.com/dart-lang/usage
author: Dart Team <misc@dartlang.org>
diff --git a/test/hit_types_test.dart b/test/hit_types_test.dart
index a7ee490..1dc0895 100644
--- a/test/hit_types_test.dart
+++ b/test/hit_types_test.dart
@@ -100,7 +100,7 @@
AnalyticsTimer timer =
mock.startTimer('compile', category: 'Build', label: 'Compile');
- await new Future.delayed(new Duration(milliseconds: 20));
+ await Future.delayed(Duration(milliseconds: 20));
await timer.finish();
expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
@@ -112,7 +112,7 @@
int time = timer.currentElapsedMillis;
expect(time, greaterThan(10));
- await new Future.delayed(new Duration(milliseconds: 10));
+ await Future.delayed(Duration(milliseconds: 10));
expect(timer.currentElapsedMillis, time);
});
});
diff --git a/test/src/common.dart b/test/src/common.dart
index c2f1a5e..bcdabf6 100644
--- a/test/src/common.dart
+++ b/test/src/common.dart
@@ -10,7 +10,7 @@
import 'package:usage/src/usage_impl.dart';
AnalyticsImplMock createMock({Map<String, dynamic> props}) =>
- new AnalyticsImplMock('UA-0', props: props);
+ AnalyticsImplMock('UA-0', props: props);
void was(Map m, String type) => expect(m['t'], type);
void has(Map m, String key) => expect(m[key], isNotNull);
@@ -21,7 +21,7 @@
MockPostHandler get mockPostHandler => postHandler;
AnalyticsImplMock(String trackingId, {Map<String, dynamic> props})
- : super(trackingId, new MockProperties(props), new MockPostHandler(),
+ : super(trackingId, MockProperties(props), MockPostHandler(),
applicationName: 'Test App', applicationVersion: '0.1');
Map<String, dynamic> get last => mockPostHandler.last;
@@ -53,7 +53,7 @@
Future sendPost(String url, Map<String, dynamic> parameters) {
sentValues.add(parameters);
- return new Future.value();
+ return Future.value();
}
Map<String, dynamic> get last => sentValues.last;
diff --git a/test/usage_impl_io_test.dart b/test/usage_impl_io_test.dart
index a9c30d4..ffc760c 100644
--- a/test/usage_impl_io_test.dart
+++ b/test/usage_impl_io_test.dart
@@ -16,8 +16,8 @@
void defineTests() {
group('IOPostHandler', () {
test('sendPost', () async {
- var httpClient = new MockHttpClient();
- IOPostHandler postHandler = new IOPostHandler(mockClient: httpClient);
+ var httpClient = MockHttpClient();
+ IOPostHandler postHandler = IOPostHandler(mockClient: httpClient);
Map<String, dynamic> args = {'utv': 'varName', 'utt': 123};
await postHandler.sendPost('http://www.google.com', args);
expect(httpClient.sendCount, 1);
@@ -26,13 +26,13 @@
group('IOPersistentProperties', () {
test('add', () {
- IOPersistentProperties props = new IOPersistentProperties('foo_props');
+ IOPersistentProperties props = IOPersistentProperties('foo_props');
props['foo'] = 'bar';
expect(props['foo'], 'bar');
});
test('remove', () {
- IOPersistentProperties props = new IOPersistentProperties('foo_props');
+ IOPersistentProperties props = IOPersistentProperties('foo_props');
props['foo'] = 'bar';
expect(props['foo'], 'bar');
props['foo'] = null;
@@ -60,7 +60,7 @@
@override
Future<HttpClientRequest> postUrl(Uri url) {
- return new Future.value(new MockHttpClientRequest(this));
+ return Future.value(MockHttpClientRequest(this));
}
@override
@@ -80,7 +80,7 @@
@override
Future<HttpClientResponse> close() {
client.closed = true;
- return new Future.value(new MockHttpClientResponse(client));
+ return Future.value(MockHttpClientResponse(client));
}
@override
@@ -95,7 +95,7 @@
@override
Future<E> drain<E>([E futureValue]) {
client.sendCount++;
- return new Future.value();
+ return Future.value();
}
@override
diff --git a/test/usage_impl_test.dart b/test/usage_impl_test.dart
index 2a3ea35..8980679 100644
--- a/test/usage_impl_test.dart
+++ b/test/usage_impl_test.dart
@@ -14,12 +14,12 @@
void defineTests() {
group('ThrottlingBucket', () {
test('can send', () {
- ThrottlingBucket bucket = new ThrottlingBucket(20);
+ ThrottlingBucket bucket = ThrottlingBucket(20);
expect(bucket.removeDrop(), true);
});
test('doesn\'t send too many', () {
- ThrottlingBucket bucket = new ThrottlingBucket(20);
+ ThrottlingBucket bucket = ThrottlingBucket(20);
for (int i = 0; i < 20; i++) {
expect(bucket.removeDrop(), true);
}
@@ -75,7 +75,7 @@
mock.sendScreenView('foo');
mock.sendScreenView('bar');
mock.sendScreenView('baz');
- return mock.waitForLastPing(timeout: new Duration(milliseconds: 100));
+ return mock.waitForLastPing(timeout: Duration(milliseconds: 100));
});
group('clientId', () {
diff --git a/test/usage_test.dart b/test/usage_test.dart
index d97d7b4..a7ae138 100644
--- a/test/usage_test.dart
+++ b/test/usage_test.dart
@@ -12,7 +12,7 @@
void defineTests() {
group('AnalyticsMock', () {
test('simple', () {
- AnalyticsMock mock = new AnalyticsMock();
+ AnalyticsMock mock = AnalyticsMock();
mock.sendScreenView('main');
mock.sendScreenView('withParameters', parameters: {'cd1': 'custom'});
mock.sendEvent('files', 'save');
diff --git a/test/uuid_test.dart b/test/uuid_test.dart
index 81762e7..d85a4a1 100644
--- a/test/uuid_test.dart
+++ b/test/uuid_test.dart
@@ -13,7 +13,7 @@
group('uuid', () {
// xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
test('simple', () {
- Uuid uuid = new Uuid();
+ Uuid uuid = Uuid();
String result = uuid.generateV4();
expect(result.length, 36);
expect(result[8], '-');
@@ -23,7 +23,7 @@
});
test('can parse', () {
- Uuid uuid = new Uuid();
+ Uuid uuid = Uuid();
String result = uuid.generateV4();
expect(int.parse(result.substring(0, 8), radix: 16), isNotNull);
expect(int.parse(result.substring(9, 13), radix: 16), isNotNull);
@@ -33,7 +33,7 @@
});
test('special bits', () {
- Uuid uuid = new Uuid();
+ Uuid uuid = Uuid();
String result = uuid.generateV4();
expect(result[14], '4');
expect(result[19].toLowerCase(), isIn('89ab'));
@@ -46,23 +46,23 @@
});
test('is pretty random', () {
- Set set = new Set();
+ Set set = Set();
- Uuid uuid = new Uuid();
+ Uuid uuid = Uuid();
for (int i = 0; i < 64; i++) {
String val = uuid.generateV4();
expect(set, isNot(contains(val)));
set.add(val);
}
- uuid = new Uuid();
+ uuid = Uuid();
for (int i = 0; i < 64; i++) {
String val = uuid.generateV4();
expect(set, isNot(contains(val)));
set.add(val);
}
- uuid = new Uuid();
+ uuid = Uuid();
for (int i = 0; i < 64; i++) {
String val = uuid.generateV4();
expect(set, isNot(contains(val)));
diff --git a/test/web_test.dart b/test/web_test.dart
index 1162559..da6b4a9 100644
--- a/test/web_test.dart
+++ b/test/web_test.dart
@@ -30,9 +30,9 @@
void defineWebTests() {
group('HtmlPostHandler', () {
test('sendPost', () async {
- MockRequestor client = new MockRequestor();
+ MockRequestor client = MockRequestor();
HtmlPostHandler postHandler =
- new HtmlPostHandler(mockRequestor: client.request);
+ HtmlPostHandler(mockRequestor: client.request);
Map<String, dynamic> args = {'utv': 'varName', 'utt': 123};
await postHandler.sendPost('http://www.google.com', args);
@@ -42,15 +42,13 @@
group('HtmlPersistentProperties', () {
test('add', () {
- HtmlPersistentProperties props =
- new HtmlPersistentProperties('foo_props');
+ HtmlPersistentProperties props = HtmlPersistentProperties('foo_props');
props['foo'] = 'bar';
expect(props['foo'], 'bar');
});
test('remove', () {
- HtmlPersistentProperties props =
- new HtmlPersistentProperties('foo_props');
+ HtmlPersistentProperties props = HtmlPersistentProperties('foo_props');
props['foo'] = 'bar';
expect(props['foo'], 'bar');
props['foo'] = null;
@@ -68,6 +66,6 @@
expect(sendData, isNotEmpty);
sendCount++;
- return new Future.value();
+ return Future.value();
}
}
diff --git a/tool/grind.dart b/tool/grind.dart
index f93261b..2f9d613 100644
--- a/tool/grind.dart
+++ b/tool/grind.dart
@@ -8,7 +8,7 @@
import 'package:grinder/grinder.dart';
-final Directory _buildExampleDir = new Directory('build/example');
+final Directory _buildExampleDir = Directory('build/example');
main(List<String> args) => grind(args);
@@ -19,7 +19,7 @@
@Depends(init)
void build() {
// Compile `test/web_test.dart` to the `build/test` dir; measure its size.
- File srcFile = new File('example/example.dart');
+ File srcFile = File('example/example.dart');
Dart2js.compile(srcFile,
outDir: _buildExampleDir,
minify: true,