summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint/files/pkglint.go
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2018-01-28 23:21:16 +0000
committerrillig <rillig@pkgsrc.org>2018-01-28 23:21:16 +0000
commit90ca88236b6927e3ecd596c2e4538b7d154b2d23 (patch)
treebaaf41e209e87f2382c749dfb5378976cf9b9186 /pkgtools/pkglint/files/pkglint.go
parent1bf85a634ceb83c7d3889697ddd61a7d403d9207 (diff)
downloadpkgsrc-90ca88236b6927e3ecd596c2e4538b7d154b2d23.tar.gz
pkgtools/pkglint: update to 5.5.3
Changes since 5.5.2: * Fixed lots of bugs regarding autofixing variable assignments in continuation lines. * Fixed checking of MESSAGE files, which also get fixed now. * In variable assignments, commented assignments are aligned too. * Fixed a crash when checking an empty patch file. * The :Q modifier is only checked on predefined variables, to prevent the --autofix mode from removing :Q from user-defined variables. * Fixed lots of bugs in PLIST autofixing: relevant lines had been removed, and the sorting was not correct.
Diffstat (limited to 'pkgtools/pkglint/files/pkglint.go')
-rw-r--r--pkgtools/pkglint/files/pkglint.go34
1 files changed, 21 insertions, 13 deletions
diff --git a/pkgtools/pkglint/files/pkglint.go b/pkgtools/pkglint/files/pkglint.go
index 03b9c1e749a..a20b46a11da 100644
--- a/pkgtools/pkglint/files/pkglint.go
+++ b/pkgtools/pkglint/files/pkglint.go
@@ -308,37 +308,45 @@ func ChecklinesMessage(lines []Line) {
defer trace.Call1(lines[0].Filename)()
}
- explainMessage := func() {
- Explain(
- "A MESSAGE file should consist of a header line, having 75 \"=\"",
- "characters, followed by a line containing only the RCS Id, then an",
- "empty line, your text and finally the footer line, which is the",
- "same as the header line.")
- }
+ explanation := []string{
+ "A MESSAGE file should consist of a header line, having 75 \"=\"",
+ "characters, followed by a line containing only the RCS Id, then an",
+ "empty line, your text and finally the footer line, which is the",
+ "same as the header line."}
if len(lines) < 3 {
lastLine := lines[len(lines)-1]
lastLine.Warnf("File too short.")
- explainMessage()
+ Explain(explanation...)
return
}
hline := strings.Repeat("=", 75)
if line := lines[0]; line.Text != hline {
- line.Warnf("Expected a line of exactly 75 \"=\" characters.")
- explainMessage()
+ fix := line.Autofix()
+ fix.Warnf("Expected a line of exactly 75 \"=\" characters.")
+ fix.Explain(explanation...)
+ fix.InsertBefore(hline)
+ fix.Apply()
+ CheckLineRcsid(lines[0], ``, "")
+ } else if 1 < len(lines) {
+ CheckLineRcsid(lines[1], ``, "")
}
- CheckLineRcsid(lines[1], ``, "")
for _, line := range lines {
CheckLineLength(line, 80)
CheckLineTrailingWhitespace(line)
CheckLineValidCharacters(line, `[\t -~]`)
}
if lastLine := lines[len(lines)-1]; lastLine.Text != hline {
- lastLine.Warnf("Expected a line of exactly 75 \"=\" characters.")
- explainMessage()
+ fix := lastLine.Autofix()
+ fix.Warnf("Expected a line of exactly 75 \"=\" characters.")
+ fix.Explain(explanation...)
+ fix.InsertAfter(hline)
+ fix.Apply()
}
ChecklinesTrailingEmptyLines(lines)
+
+ SaveAutofixChanges(lines)
}
func CheckfileMk(fname string) {