fix: format-comment
is listing the macros from dart doc.
#823
Conversation
Dart Code Metrics unused files report of dart_code_metrics. ✅Summary
|
Dart Code Metrics analyze report of dart_code_metrics. ✅Summary
|
Codecov Report
@@ Coverage Diff @@
## master #823 +/- ##
=======================================
Coverage 87.32% 87.32%
=======================================
Files 279 279
Lines 5931 5932 +1
=======================================
+ Hits 5179 5180 +1
Misses 752 752
Continue to review full report at Codecov.
|
final regTemplateExp = RegExp(r"{@template [\w'-]+}"); | ||
final regMacroExp = RegExp(r"{@macro [\w'-]+}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make them file-private final variables. It can look like a micro-optimization, but for analyzer running on thousands comments that could matter.
E.g. this benchmark:
import 'package:benchmark/benchmark.dart';
void main() {
benchmark('Create RegExp', () {
List.generate(100000, (i) {
final x = RegExp(r"{@template [\w'-]+}");
return x.hasMatch('abc');
});
});
benchmark('Reuse RegExp', () {
List.generate(100000, (i) {
return _regex.hasMatch('abc');
});
});
}
final _regex = RegExp(r"{@template [\w'-]+}");
gives such a result:
❯ dart run benchmark --dir=.
DONE ././lib/example_benchmark.dart (5 s)
✓ Create RegExp (103 ms)
✓ Reuse RegExp (22 ms)
Benchmark suites: 1 passed, 1 total
Benchmarks: 2 passed, 2 total
Time: 5 s
Ran all benchmark suites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, actually!
final _regTemplateExp = RegExp(r"{@template [\w'-]+}"); | ||
final _regMacroExp = RegExp(r"{@macro [\w'-]+}"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the examples I've seen online also use .
in the template names. And this is supported by dartdoc.
ex:
/// {@template my_project.my_class.my_method}
Wouldn't this be better?
final _regTemplateExp = RegExp(r"{@template [\w'-]+}"); | |
final _regMacroExp = RegExp(r"{@macro [\w'-]+}"); | |
final _regTemplateExp = RegExp(r"{@template [\w'-\.]+}"); | |
final _regMacroExp = RegExp(r"{@macro [\w'-\.]+}"); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it can even be combined and simplified to r'{@(template|macro) .+}'
.
I don't see any actual profit in making it stricter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done))
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[X] Bug fix
[ ] New rule
[ ] Changes an existing rule
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
#812
What changes did you make? (Give an overview)
Is there anything you'd like reviewers to focus on?