diff --git a/godot.go b/godot.go index c538139..b98da02 100644 --- a/godot.go +++ b/godot.go @@ -124,7 +124,7 @@ func checkComment(comment string) (line int, ok bool) { func checkLastChar(s string) bool { // Don't check comments starting with space indentation - they may // contain code examples, which shouldn't end with period - if strings.HasPrefix(s, " ") || strings.HasPrefix(s, "\t") { + if strings.HasPrefix(s, " ") || strings.HasPrefix(s, " \t") || strings.HasPrefix(s, "\t") { return true } s = strings.TrimSpace(s) diff --git a/godot_test.go b/godot_test.go index 0f1ad06..2d6f5d5 100644 --- a/godot_test.go +++ b/godot_test.go @@ -58,6 +58,12 @@ func TestCheckComment(t *testing.T) { ok: true, line: 0, }, + { + name: "singleline comment: code example without period and mixed indentation", + comment: "// \tx == y", + ok: true, + line: 0, + }, { name: "singleline comment: empty line", comment: "//", diff --git a/testdata/example_checkall.go b/testdata/example_checkall.go index 8468593..e011487 100644 --- a/testdata/example_checkall.go +++ b/testdata/example_checkall.go @@ -42,7 +42,7 @@ type ObjectX struct { } // Declaration comment without a period, with an indented code example: -// co := ComplexObject{} +// co := ComplexObjectX{} // fmt.Println(co) // PASS type ComplexObjectX struct { // Exported field comment - always PASS @@ -51,6 +51,13 @@ type ComplexObjectX struct { secret int } +// Declaration comment without a period, with a mixed indented code example: +// co := MessageX{} +// fmt.Println(co) // PASS +type MessageX struct { + Type string +} + // Declaration multiline comment // second line // third line with a period PASS. diff --git a/testdata/example_default.go b/testdata/example_default.go index 3177c38..836ea08 100644 --- a/testdata/example_default.go +++ b/testdata/example_default.go @@ -51,6 +51,13 @@ type ComplexObject struct { secret int } +// Declaration comment without a period, with a mixed indented code example: +// co := Message{} +// fmt.Println(co) // PASS +type Message struct { + Type string +} + // Declaration multiline comment // second line // third line with a period PASS.