Reflow comments to 80 characters (#59)
- Find comment lines longer than 80 characters and reflow to under than
80 characters. Leave URLs as is.
- Remove some noise words "string representation" from a doc comment -
the signature tells us it is a `String`.
- Add some blank lines to reformat a doc comment. Indent example stack
traces lines like a code block.
- Remove the noise word "correctly" from a test case so it fits under 80
characters.
- Remove an unnecessary trailing whitespace.
diff --git a/lib/src/frame.dart b/lib/src/frame.dart
index 53ae619..23909f8 100644
--- a/lib/src/frame.dart
+++ b/lib/src/frame.dart
@@ -134,8 +134,8 @@
/// Parses a string representation of a Dart VM stack frame.
factory Frame.parseVM(String frame) => _catchFormatException(frame, () {
- // The VM sometimes folds multiple stack frames together and replaces them
- // with "...".
+ // The VM sometimes folds multiple stack frames together and replaces
+ // them with "...".
if (frame == '...') {
return new Frame(new Uri(), null, null, '...');
}
@@ -163,8 +163,8 @@
var match = _v8Frame.firstMatch(frame);
if (match == null) return new UnparsedFrame(frame);
- // v8 location strings can be arbitrarily-nested, since it adds a layer of
- // nesting for each eval performed on that line.
+ // v8 location strings can be arbitrarily-nested, since it adds a layer
+ // of nesting for each eval performed on that line.
parseLocation(location, member) {
var evalMatch = _v8EvalLocation.firstMatch(location);
while (evalMatch != null) {
@@ -185,9 +185,9 @@
// V8 stack frames can be in two forms.
if (match[2] != null) {
- // The first form looks like " at FUNCTION (LOCATION)". V8 proper lists
- // anonymous functions within eval as "<anonymous>", while IE10 lists them
- // as "Anonymous function".
+ // The first form looks like " at FUNCTION (LOCATION)". V8 proper
+ // lists anonymous functions within eval as "<anonymous>", while IE10
+ // lists them as "Anonymous function".
return parseLocation(
match[2],
match[1]
@@ -195,8 +195,8 @@
.replaceAll("Anonymous function", "<fn>")
.replaceAll("(anonymous function)", "<fn>"));
} else {
- // The second form looks like " at LOCATION", and is used for anonymous
- // functions.
+ // The second form looks like " at LOCATION", and is used for
+ // anonymous functions.
return parseLocation(match[3], "<fn>");
}
});
@@ -210,7 +210,7 @@
/// be retrieved.
factory Frame.parseIE(String frame) => new Frame.parseV8(frame);
- /// Parses a string representation of a Firefox 'eval' or 'function' stack frame.
+ /// Parses a Firefox 'eval' or 'function' stack frame.
///
/// for example:
/// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > Function:3:40
@@ -247,8 +247,8 @@
new List.filled('/'.allMatches(match[2]).length, ".<fn>").join();
if (member == '') member = '<fn>';
- // Some Firefox members have initial dots. We remove them for consistency
- // with other platforms.
+ // Some Firefox members have initial dots. We remove them for
+ // consistency with other platforms.
member = member.replaceFirst(_initialDot, '');
} else {
member = '<fn>';
@@ -279,12 +279,13 @@
"Couldn't parse package:stack_trace stack trace line '$frame'.");
}
// Fake truncated data urls generated by the friendly stack trace format
- // cause Uri.parse to throw an exception so we have to special case them.
+ // cause Uri.parse to throw an exception so we have to special case
+ // them.
var uri = match[1] == 'data:...'
? new Uri.dataFromString('')
: Uri.parse(match[1]);
- // If there's no scheme, this is a relative URI. We should interpret it as
- // relative to the current working directory.
+ // If there's no scheme, this is a relative URI. We should interpret it
+ // as relative to the current working directory.
if (uri.scheme == '') {
uri = path.toUri(path.absolute(path.fromUri(uri)));
}
diff --git a/lib/src/trace.dart b/lib/src/trace.dart
index 9baff1c..09c1ca1 100644
--- a/lib/src/trace.dart
+++ b/lib/src/trace.dart
@@ -28,10 +28,12 @@
final _v8TraceLine = new RegExp(r" ?at ");
/// A RegExp to match Firefox's eval and Function stack traces.
+///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack
+///
/// These stack traces looks like:
-/// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > Function:3:40
-/// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > eval:3:40
+/// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > Function:3:40
+/// anonymous/<@http://pub.dartlang.org/stuff.js line 693 > eval:3:40
final _firefoxEvalTrace =
new RegExp(r"@\S+ line \d+ >.* (Function|eval):\d+:\d+");
@@ -172,8 +174,8 @@
trace
.split("\n")
.skip(1)
- // It's possible that an Exception's description contains a line that
- // looks like a V8 trace line, which will screw this up.
+ // It's possible that an Exception's description contains a line
+ // that looks like a V8 trace line, which will screw this up.
// Unfortunately, that's impossible to detect.
.skipWhile((line) => !line.startsWith(_v8TraceLine))
.map((line) => new Frame.parseV8(line)),
diff --git a/test/frame_test.dart b/test/frame_test.dart
index 1ec3c99..4e46a55 100644
--- a/test/frame_test.dart
+++ b/test/frame_test.dart
@@ -259,13 +259,12 @@
expect(trace.frames[2].member, equals("baz"));
});
- test(
- 'parses a Firefox stack trace with nested evals in anonymous function correctly',
+ test('parses a Firefox stack trace with nested evals in anonymous function',
() {
var trace = new Trace.parse('''
Foo._bar@http://pub.dartlang.org/stuff.js:18056:12
anonymous@file:///C:/example.html line 7 > eval line 1 > eval:1:1
- anonymous@file:///C:/example.html line 45 > Function:1:1
+ anonymous@file:///C:/example.html line 45 > Function:1:1
''');
expect(trace.frames[0].uri,
equals(Uri.parse("http://pub.dartlang.org/stuff.js")));