Skip to content

Commit

Permalink
Add support for yaml files (#194)
Browse files Browse the repository at this point in the history
* Add support for yaml files

* Add yaml integration test

Co-authored-by: Preslav Mihaylov <pmihaylov95@gmail.com>
  • Loading branch information
Jasper-Ben and preslavmihaylov authored Sep 12, 2022
1 parent e1a8e59 commit 91e3e2d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tmp/
todocheck
testing/authtokens.yaml
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ Based on this, here are the supported languages:
| Scala | `*.scala`, `*.sc` extensions. Supports single-line `//` comments and multi-line `/* */` comments |
| Swift | `*.swift` extension. Supports single-line `//` comments and multi-line `/* */` comments
| Vue | `*.vue` extension. Supports single-line `//` comments, multi-line `/* */` comments and multi-line `<!-- -->` HTML comments |
| Yaml | `*.yaml`, `*.yml` extension. Supports `#` single-line comments |

If you don't see your favorite language in this table, but it does use one of the supported comment formats, submit an issue [here](https://github.com/preslavmihaylov/todocheck/issues/new)

Expand Down
2 changes: 2 additions & 0 deletions matchers/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ var supportedMatchers = map[string]*matcherFactory{
".bash": scriptsMatcherFactory,
".zsh": scriptsMatcherFactory,
".R": scriptsMatcherFactory,
".yaml": scriptsMatcherFactory,
".yml": scriptsMatcherFactory,

// file types, supporting php comments
".php": phpMatcherFactory,
Expand Down
9 changes: 9 additions & 0 deletions testing/scenarios/scripts/file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is a yaml file

# A malformed TODO comment

# TODO 123: This is a valid todo comment

# TODO 321: This is an invalid todo, marked against a closed issue

foo: bar # TODO 567: This is an invalid todo, marked against a non-existent issue
9 changes: 9 additions & 0 deletions testing/scenarios/scripts/file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is a yaml file

# A malformed TODO comment

# TODO 123: This is a valid todo comment

# TODO 321: This is an invalid todo, marked against a closed issue

foo: bar # TODO 567: This is an invalid todo, marked against a non-existent issue
30 changes: 30 additions & 0 deletions testing/todocheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,36 @@ func TestScriptsTodos(t *testing.T) {
WithType(errors.TODOErrTypeNonExistentIssue).
WithLocation("scenarios/scripts/script.bash", 9).
ExpectLine("curl \"localhost:8080\" # TODO 567: This is an invalid todo, marked against a non-existent issue")).
ExpectTodoErr(
scenariobuilder.NewTodoErr().
WithType(errors.TODOErrTypeMalformed).
WithLocation("scenarios/scripts/file.yaml", 3).
ExpectLine("# A malformed TODO comment")).
ExpectTodoErr(
scenariobuilder.NewTodoErr().
WithType(errors.TODOErrTypeIssueClosed).
WithLocation("scenarios/scripts/file.yaml", 7).
ExpectLine("# TODO 321: This is an invalid todo, marked against a closed issue")).
ExpectTodoErr(
scenariobuilder.NewTodoErr().
WithType(errors.TODOErrTypeNonExistentIssue).
WithLocation("scenarios/scripts/file.yaml", 9).
ExpectLine("foo: bar # TODO 567: This is an invalid todo, marked against a non-existent issue")).
ExpectTodoErr(
scenariobuilder.NewTodoErr().
WithType(errors.TODOErrTypeMalformed).
WithLocation("scenarios/scripts/file.yml", 3).
ExpectLine("# A malformed TODO comment")).
ExpectTodoErr(
scenariobuilder.NewTodoErr().
WithType(errors.TODOErrTypeIssueClosed).
WithLocation("scenarios/scripts/file.yml", 7).
ExpectLine("# TODO 321: This is an invalid todo, marked against a closed issue")).
ExpectTodoErr(
scenariobuilder.NewTodoErr().
WithType(errors.TODOErrTypeNonExistentIssue).
WithLocation("scenarios/scripts/file.yml", 9).
ExpectLine("foo: bar # TODO 567: This is an invalid todo, marked against a non-existent issue")).
Run()
if err != nil {
t.Errorf("%s", err)
Expand Down

0 comments on commit 91e3e2d

Please sign in to comment.