Skip to content

Panic with incorrect input #92

@johejo

Description

@johejo

How to reproduce

package errorformat_test

import (
	"testing"

	"github.com/reviewdog/errorformat"
)

func TestPanic(t *testing.T) {
	_, err := errorformat.NewEfm("%")
	if err == nil {
		t.Fatal("should return error")
	}
}
--- FAIL: TestPanic (0.00s)
panic: runtime error: index out of range [1] with length 1 [recovered]
        panic: runtime error: index out of range [1] with length 1

goroutine 33 [running]:
testing.tRunner.func1.1(0x5406c0, 0xc000154020)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1072 +0x30d
testing.tRunner.func1(0xc000102480)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1075 +0x41a
panic(0x5406c0, 0xc000154020)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/runtime/panic.go:969 +0x1b9
github.com/reviewdog/errorformat.NewEfm.func1(...)
        /home/heijo/ghq/github.com/reviewdog/errorformat/errorformat.go:435
github.com/reviewdog/errorformat.NewEfm(0x54feb1, 0x1, 0xc00005e770, 0x47e246, 0x60281766)
        /home/heijo/ghq/github.com/reviewdog/errorformat/errorformat.go:442 +0x93f
github.com/reviewdog/errorformat_test.TestPanic(0xc000102480)
        /home/heijo/ghq/github.com/reviewdog/errorformat/panic_test.go:10 +0x3a
testing.tRunner(0xc000102480, 0x55b548)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1123 +0xef
created by testing.(*T).Run
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1168 +0x2b3
exit status 2
FAIL    github.com/reviewdog/errorformat        0.004s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions