errata-ai / vale

:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
https://vale.sh
MIT License
4.45k stars 153 forks source link

Vale 2.6.1: panic: runtime error: index out of range [1] with length 1 #268

Closed ghost closed 3 years ago

ghost commented 3 years ago

Summary

In the test case described below:

This appears to be some interaction between Chicago style titles, and the word config appearing in the accept.txt Vocab file.

Environment

Example

PS > vale -v
vale version 2.6.1

PS > vale .\test.md
panic: runtime error: index out of range [1] with length 1

goroutine 12 [running]:
github.com/errata-ai/vale/v2/check.title(0xc000b924d0, 0xd, 0xc000464aa0, 0x2, 0x2, 0xc0000e9dc0, 0xc0004740e0, 0xc00030f938)
        /home/travis/gopath/src/github.com/errata-ai/vale/check/variables.go:39 +0x31c
github.com/errata-ai/vale/v2/check.NewCapitalization.func1(0xc000b924d0, 0xd, 0xc000464aa0, 0x2, 0x2, 0xc0000e9dc0, 0x1a80050000000004)
        /home/travis/gopath/src/github.com/errata-ai/vale/check/capitalization.go:54 +0x6d
github.com/errata-ai/vale/v2/check.Capitalization.Run(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000b70960, 0xe, ...)
        /home/travis/gopath/src/github.com/errata-ai/vale/check/capitalization.go:78 +0x93
github.com/errata-ai/vale/v2/lint.(*Linter).lintText.func1(0xc0000640c0, 0xc000b92500, 0xc000b924d0, 0xd, 0xc000b70910, 0xd, 0xc000514dc0, 0xf99b40, 0xc0003178c0)
        /home/travis/gopath/src/github.com/errata-ai/vale/lint/lint.go:260 +0xc1
created by github.com/errata-ai/vale/v2/lint.(*Linter).lintText
        /home/travis/gopath/src/github.com/errata-ai/vale/lint/lint.go:258 +0x383

Test Case

I've created a test, attached as ValePanic.zip, which contains:

Contents of test.md

# configuration

Contents of .vale.ini

###########################################
# Vale configuration
## https://docs.errata.ai/vale/about
###########################################

StylesPath = ".vale"
MinAlertLevel = suggestion
Vocab = test

[formats]
## Check Markdown files.
[*.md]
BasedOnStyles = test, Vale

Contents of .vale/test/Headings.yml

---
# The Vultr Markdown Toolkit is released under the Creative Commons Attribution 4.0 International (CC BY 4.0) license.
# https://creativecommons.org/licenses/by/4.0/
#
extends: capitalization
message: "Headings should use title case. Vultr follows the Chicago Manual of Style. "
link: https://capitalizemytitle.com/style/chicago
level: error
scope: heading
match: $title
style: Chicago
exceptions:
  - macOS

Contents of .vale/Vocab/test/accept.txt

config

.vale/Vocab/test/reject.txt is zero bytes.

jdkato commented 3 years ago

Thanks for the detailed report.

I've identified the issue and it'll be fixed in the next release.