Skip to content

Commit

Permalink
Prohibit vertical bar in COMMENT
Browse files Browse the repository at this point in the history
This character breaks the INDEX export, generating more columns than
expected.
  • Loading branch information
rillig committed Oct 4, 2024
1 parent f6c6218 commit 7562438
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 9 additions & 1 deletion v23/vartypecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,15 @@ func (cv *VartypeCheck) Comment() {

if hasPrefix(value, "\"") && hasSuffix(value, "\"") ||
hasPrefix(value, "'") && hasSuffix(value, "'") {
cv.Warnf("COMMENT should not be enclosed in quotes.")
cv.Errorf("COMMENT must not be enclosed in quotes.")
}

if contains(value, "|") {
cv.Errorf("COMMENT must not contain \"|\".")
cv.Explain(
"The vertical bar is used as a separator",
"in the package summary,",
"where it cannot be escaped.")
}
}

Expand Down
10 changes: 6 additions & 4 deletions v23/vartypecheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,24 @@ func (s *Suite) Test_VartypeCheck_Comment(c *check.C) {
"Converter converts between measurement units",
"Converter is a unit converter",
"\"Official\" office suite",
"'SQL injection fuzzer")
"'SQL injection fuzzer",
"TCR (Test && Commit || Revert) utility")

vt.Output(
"ERROR: filename.mk:2: COMMENT must be set.",
"WARN: filename.mk:3: COMMENT should not begin with \"A\".",
"WARN: filename.mk:3: COMMENT should not end with a period.",
"WARN: filename.mk:4: COMMENT should start with a capital letter.",
"WARN: filename.mk:4: COMMENT should not be longer than 70 characters.",
"WARN: filename.mk:5: COMMENT should not be enclosed in quotes.",
"WARN: filename.mk:6: COMMENT should not be enclosed in quotes.",
"ERROR: filename.mk:5: COMMENT must not be enclosed in quotes.",
"ERROR: filename.mk:6: COMMENT must not be enclosed in quotes.",
"WARN: filename.mk:7: COMMENT should not contain \"is a\".",
"WARN: filename.mk:8: COMMENT should not contain \"is an\".",
"WARN: filename.mk:9: COMMENT should not contain \"is a\".",
"WARN: filename.mk:10: COMMENT should not start with the package name.",
"WARN: filename.mk:11: COMMENT should not start with the package name.",
"WARN: filename.mk:11: COMMENT should not contain \"is a\".")
"WARN: filename.mk:11: COMMENT should not contain \"is a\".",
"ERROR: filename.mk:14: COMMENT must not contain \"|\".")
}

func (s *Suite) Test_VartypeCheck_ConfFiles(c *check.C) {
Expand Down

0 comments on commit 7562438

Please sign in to comment.