yoheimuta/protolint

Stray double semi-colon cause erratic results

Opened this issue · 0 comments

Client version: 0.46.2(e359414)

When a proto files contain stray double semi-colons, dependent on where in the .proto it is, two unexpected behaviours are displayed.


Error 1

If the extra semi-colon is found in a message or enum section, e.g.

message Example {
  string key = 1;;
  string value = 2;
}

Expected behaviour: The additional symbol should be flagged and a warning returned
Displayed behaviour: The proto file validates


Error 2

If the extra semi-colon is found in imports or options, e.g.

import "types/debug.proto";
import "types/failure.proto";;
import "types/meta.proto";

Expected behaviour: The additional symbol should be flagged and a warning returned
Displayed behaviour: The linter hits a nil pointer exception and panics

Panic trace
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x1050bf434]

goroutine 1 [running]:
github.com/yoheimuta/go-protoparser/v4/parser.(*Proto).Accept(0x1400009b770?, {0x1056919d0, 0x14000316708})
	/home/runner/go/pkg/mod/github.com/yoheimuta/go-protoparser/v4@v4.7.0/parser/proto.go:26 +0x64
github.com/yoheimuta/protolint/linter/visitor.RunVisitorAutoDisable({0x105692b28?, 0x14000485bc0?}, 0x1400009b770, {0x105471068, 0x10}, 0x5?)
	/home/runner/work/protolint/protolint/linter/visitor/hasExtendedVisitor.go:55 +0x104
github.com/yoheimuta/protolint/linter/visitor.RunVisitor(...)
	/home/runner/work/protolint/protolint/linter/visitor/hasExtendedVisitor.go:28
github.com/yoheimuta/protolint/internal/addon/rules.QuoteConsistentRule.Apply({{{0x1054688b0?, 0x0?}}, 0x10547476b?, 0x15?}, 0x1400003ea24?)
	/home/runner/work/protolint/protolint/internal/addon/rules/quoteConsistentRule.go:60 +0xac
github.com/yoheimuta/protolint/internal/linter.(*Linter).Run(0x16ae4f39d?, 0x1400051d728, {0x1400021f000?, 0xc, 0x0?})
	/home/runner/work/protolint/protolint/internal/linter/linter.go:33 +0x108
github.com/yoheimuta/protolint/internal/cmd/subcmds/lint.(*CmdLint).runOneFile(0x140001d2700, {{0x1400003ea00, 0x40}, {0x1400003ea24, 0x1c}})
	/home/runner/work/protolint/protolint/internal/cmd/subcmds/lint/cmdLint.go:131 +0x108
github.com/yoheimuta/protolint/internal/cmd/subcmds/lint.(*CmdLint).run(0x140001d2700)
	/home/runner/work/protolint/protolint/internal/cmd/subcmds/lint/cmdLint.go:100 +0xd8
github.com/yoheimuta/protolint/internal/cmd/subcmds/lint.(*CmdLint).Run(0x140001d2700)
	/home/runner/work/protolint/protolint/internal/cmd/subcmds/lint/cmdLint.go:77 +0x44
github.com/yoheimuta/protolint/internal/cmd.doLint({0x140000300a0?, 0x400000?, 0x1400006a658?}, {0x105686128, 0x1400006e028}, {0x105686128, 0x1400006e030})
	/home/runner/work/protolint/protolint/internal/cmd/cmd.go:110 +0x1f0
github.com/yoheimuta/protolint/internal/cmd.doSub({0x14000030090?, 0x104fb7ca4?, 0x14000199ec8?}, {0x105686128?, 0x1400006e028?}, {0x105686128?, 0x1400006e030?})
	/home/runner/work/protolint/protolint/internal/cmd/cmd.go:64 +0xac
github.com/yoheimuta/protolint/internal/cmd.Do({0x14000030090?, 0x0?, 0x60?}, {0x105686128?, 0x1400006e028?}, {0x105686128?, 0x1400006e030?})
	/home/runner/work/protolint/protolint/internal/cmd/cmd.go:49 +0x78
main.main()
	/home/runner/work/protolint/protolint/cmd/protolint/main.go:11 +0x70