From abad3e8873202a8796891dd6b9f6e588ba0f631f Mon Sep 17 00:00:00 2001 From: Muhammad Assad Ullah Date: Mon, 13 Jul 2026 23:57:38 +0500 Subject: [PATCH 1/3] fix: use p.join for Windows path compatibility (#250) --- dartdoc_test/lib/src/resource.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dartdoc_test/lib/src/resource.dart b/dartdoc_test/lib/src/resource.dart index f3034d7a..abfb2425 100644 --- a/dartdoc_test/lib/src/resource.dart +++ b/dartdoc_test/lib/src/resource.dart @@ -24,7 +24,7 @@ import 'package:source_span/source_span.dart'; import 'dartdoc_test.dart'; import 'model.dart'; -const _testPath = '.dart_tool/dartdoc_test'; +final _testPath = p.join('.dart_tool', 'dartdoc_test'); final _currentDir = Directory.current; From ae2020abbaa32c4c7a9c2154c29d789ad8d481b0 Mon Sep 17 00:00:00 2001 From: Muhammad Assad Ullah Date: Tue, 14 Jul 2026 00:25:28 +0500 Subject: [PATCH 2/3] fix: ensure isFailed matches actual error count in Summary The Summary class was counting errors with commentSpan differently from the isFailed check, causing 'FAILED: 0 issues found' when errors existed but without commentSpan. Now both isFailed and errors count use the same consistent logic. Fixes #275 --- dartdoc_test/lib/src/logger.dart | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dartdoc_test/lib/src/logger.dart b/dartdoc_test/lib/src/logger.dart index bbb5d830..cb065a76 100644 --- a/dartdoc_test/lib/src/logger.dart +++ b/dartdoc_test/lib/src/logger.dart @@ -90,13 +90,24 @@ class Summary { /// Get summery from [DartdocAnalysisResult]. factory Summary.from(List results) { - final isFailed = results.indexWhere((r) => r.errors.isNotEmpty) != -1; - final errors = - results.expand((r) => r.errors).where((e) => e.commentSpan != null); + // Get all errors from all results + final allErrors = results.expand((r) => r.errors); + + // Check if there are any errors at all + final isFailed = allErrors.isNotEmpty; + + // Count only errors that have a comment span (user-facing errors) + final errorsWithSpan = allErrors.where((e) => e.commentSpan != null); + + // Get all code samples final samples = results.map((r) => r.file); + + // Get unique file paths final files = samples.map((s) => s.sample.comment.span.sourceUrl?.path).toSet(); - return Summary(isFailed, errors.length, samples.length, files.length); + + return Summary( + isFailed, errorsWithSpan.length, samples.length, files.length); } @override From 683f62aff0116089337156698733f00e7e278b93 Mon Sep 17 00:00:00 2001 From: Muhammad Assad Ullah Date: Tue, 14 Jul 2026 00:31:57 +0500 Subject: [PATCH 3/3] fix: detect all main function variations in code samples The hasMain getter only detected 'void main()', causing failures for: - Future main() - main() (no return type) - Future main() Now uses regex to detect all main function declarations. Fixes #251 --- dartdoc_test/lib/src/model.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dartdoc_test/lib/src/model.dart b/dartdoc_test/lib/src/model.dart index 8043d3c4..627774ed 100644 --- a/dartdoc_test/lib/src/model.dart +++ b/dartdoc_test/lib/src/model.dart @@ -93,7 +93,16 @@ final class DocumentationCodeSample { }); /// Whether the code sample has a `main` function. - bool get hasMain => code.contains('void main()'); + /// Detects variations like: + /// - void main() + /// - Future main() + /// - Future main() + /// - main() + bool get hasMain { + // Check for any main function declaration + // Matches: main(), void main(), Future main(), Future main() + return RegExp(r'\b(Future|Future|void)?\s*main\s*\(').hasMatch(code); + } /// Create a sample by wrapping the code with a main function and imports. String wrappedCode(Directory testDir) {