From e408111612012923683a49d7f5b75b21b6b795dd Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 29 Jun 2022 09:57:55 -0700 Subject: [PATCH 1/2] Enable and fix non_constant_identifier_names lint --- analysis_options.yaml | 1 + lib/src/hitmap.dart | 6 +++--- lib/src/resolver.dart | 6 +++--- lib/src/util.dart | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 9dfba698..462c5ebd 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -44,6 +44,7 @@ linter: - implementation_imports - library_names - library_prefixes + - no_leading_underscores_for_local_identifiers - non_constant_identifier_names # - one_member_abstracts # - only_throw_errors diff --git a/lib/src/hitmap.dart b/lib/src/hitmap.dart index a80c8f24..326dfa16 100644 --- a/lib/src/hitmap.dart +++ b/lib/src/hitmap.dart @@ -99,7 +99,7 @@ class HitMap { final ignoredLines = ignoredLinesList.iterator; var hasCurrent = ignoredLines.moveNext(); - bool _shouldIgnoreLine(Iterator> ignoredRanges, int line) { + bool shouldIgnoreLine(Iterator> ignoredRanges, int line) { if (!hasCurrent || ignoredRanges.current.isEmpty) { return false; } @@ -138,7 +138,7 @@ class HitMap { final k = hits[i]; if (k is int) { // Single line. - if (_shouldIgnoreLine(ignoredLines, k)) continue; + if (shouldIgnoreLine(ignoredLines, k)) continue; addToMap(hitMap, k, hits[i + 1] as int); } else if (k is String) { @@ -147,7 +147,7 @@ class HitMap { final start = int.parse(k.substring(0, splitPos)); final end = int.parse(k.substring(splitPos + 1)); for (var j = start; j <= end; j++) { - if (_shouldIgnoreLine(ignoredLines, j)) continue; + if (shouldIgnoreLine(ignoredLines, j)) continue; addToMap(hitMap, j, hits[i + 1] as int); } diff --git a/lib/src/resolver.dart b/lib/src/resolver.dart index 9b0e9023..d2e799ca 100644 --- a/lib/src/resolver.dart +++ b/lib/src/resolver.dart @@ -77,13 +77,13 @@ class Resolver { return resolveSymbolicLinks(filePath); } if (uri.scheme == 'package') { - final _packages = this._packages; - if (_packages == null) { + final packages = _packages; + if (packages == null) { return null; } final packageName = uri.pathSegments[0]; - final packageUri = _packages[packageName]; + final packageUri = packages[packageName]; if (packageUri == null) { failed.add('$uri'); return null; diff --git a/lib/src/util.dart b/lib/src/util.dart index 42b14669..9c2090bf 100644 --- a/lib/src/util.dart +++ b/lib/src/util.dart @@ -13,7 +13,7 @@ Future retry(Future Function() f, Duration interval, {Duration? timeout}) async { var keepGoing = true; - Future _withTimeout(Future Function() f, {Duration? duration}) { + Future withTimeout(Future Function() f, {Duration? duration}) { if (duration == null) { return f(); } @@ -27,7 +27,7 @@ Future retry(Future Function() f, Duration interval, }); } - return _withTimeout(() async { + return withTimeout(() async { while (keepGoing) { try { return await f(); From bcb6331ba045eef5c9b1e3336099e69afe99d465 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 29 Jun 2022 10:09:02 -0700 Subject: [PATCH 2/2] oops --- test/lcov_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lcov_test.dart b/test/lcov_test.dart index 5d40bf63..0eeef4fb 100644 --- a/test/lcov_test.dart +++ b/test/lcov_test.dart @@ -153,7 +153,7 @@ void main() { // be very careful if you change the test file expect(res, contains(' 0| return a - b;')); - expect(res, contains('| return _withTimeout(() async {'), + expect(res, contains('| return withTimeout(() async {'), reason: 'be careful if you change lib/src/util.dart'); final hitLineRegexp = RegExp(r'\s+(\d+)\| return a \+ b;'); @@ -176,7 +176,7 @@ void main() { // be very careful if you change the test file expect(res, contains(' 0| return a - b;')); - expect(res, contains('| return _withTimeout(() async {'), + expect(res, contains('| return withTimeout(() async {'), reason: 'be careful if you change lib/src/util.dart'); final hitLineRegexp = RegExp(r'\s+(\d+)\| return a \+ b;');