Repository: preslavmihaylov/todocheck
Pull request #186 (2022-08-10 10:58:04)

Add support for .dart files
related - #171 

I have added the support for `.dart` files.

Also added a test for checking single and multiline todo

preslavmihaylov: looks good @Mussabaheen just rebase from main after #188 
Mussabaheen: @preslavmihaylov , done :)

Patch:
diff --git a/README.md b/README.md
index 2fc29db..d5de010 100644
--- a/README.md
+++ b/README.md
@@ -292,6 +292,7 @@ Based on this, here are the supported languages:
 | C                     | `*.c` extension. Supports single-line `//` comments and multi-line `/* */` comments                                    |
 | C++                   | `*.cpp` extension. Supports single-line `//` comments and multi-line `/* */` comments                                  |
 | CSharp                | `*.cs` extension. Supports single-line `//` comments and multi-line `/* */` comments                                   |
+| Dart                  | `*.dart` extension. Supports single-line `//` comments and multi-line `/* */` comments
 | Golang                | `*.go` extension. Supports single-line `//` comments and multi-line `/* */` comments                                   |
 | Groovy                | `*.groovy`, `*.gvy`, `*.gy`, `*.gsh` extensions. Supports single-line `//` comments and multi-line `/* */` comments    |
 | Java                  | `*.java` extension. Supports single-line `//` comments and multi-line `/* */` comments                                 |
diff --git a/matchers/matchers.go b/matchers/matchers.go
index 318f0fd..1f351c3 100644
--- a/matchers/matchers.go
+++ b/matchers/matchers.go
@@ -169,6 +169,7 @@ var supportedMatchers = map[string]*matcherFactory{
 	".cs":   standardMatcherFactory,
 	".js":   standardMatcherFactory,
 	".ts":   standardMatcherFactory,
+	".dart": standardMatcherFactory,
 
 	// file types, supporting standard comments \w nested multi-line comments
 	".kt":    standardMatcherWithNestedMultilineCommentsFactory,


Test patch:
diff --git a/testing/scenarios/dart/main.dart b/testing/scenarios/dart/main.dart
new file mode 100644
index 0000000..5244373
--- /dev/null
+++ b/testing/scenarios/dart/main.dart
@@ -0,0 +1,11 @@
+void main() {
+// This is a single-line malformed TODO
+/*
+This is a multiline malformed TODO
+It should be parsed properly
+*/
+// TODO 1: this is a open issue
+// TODO 2: this is a closed issue
+    print('Hello, World!');
+  
+}
\ No newline at end of file
diff --git a/testing/todocheck_test.go b/testing/todocheck_test.go
index 17399dc..4844906 100644
--- a/testing/todocheck_test.go
+++ b/testing/todocheck_test.go
@@ -307,6 +307,37 @@ func TestPythonTodos(t *testing.T) {
 	}
 }
 
+func TestDartTodos(t *testing.T) {
+	err := scenariobuilder.NewScenario().
+		WithBinary("../todocheck").
+		WithBasepath("./scenarios/dart").
+		WithConfig("./test_configs/no_issue_tracker.yaml").
+		WithIssueTracker(issuetracker.Jira).
+		WithIssue("1", issuetracker.StatusOpen).
+		WithIssue("2", issuetracker.StatusClosed).
+		ExpectTodoErr(
+			scenariobuilder.NewTodoErr().
+				WithType(errors.TODOErrTypeMalformed).
+				WithLocation("scenarios/dart/main.dart", 2).
+				ExpectLine("// This is a single-line malformed TODO")).
+		ExpectTodoErr(
+			scenariobuilder.NewTodoErr().
+				WithType(errors.TODOErrTypeMalformed).
+				WithLocation("scenarios/dart/main.dart", 3).
+				ExpectLine("/*").
+				ExpectLine("This is a multiline malformed TODO").
+				ExpectLine("It should be parsed properly").
+				ExpectLine("*/")).
+		ExpectTodoErr(
+			scenariobuilder.NewTodoErr().
+				WithType(errors.TODOErrTypeIssueClosed).
+				WithLocation("scenarios/dart/main.dart", 8).
+				ExpectLine("// TODO 2: this is a closed issue")).Run()
+	if err != nil {
+		t.Errorf("%s", err)
+	}
+}
+
 func TestAuthTokensCache(t *testing.T) {
 	err := scenariobuilder.NewScenario().
 		WithBinary("../todocheck").