summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorryoon <ryoon@pkgsrc.org>2017-10-17 03:32:28 +0000
committerryoon <ryoon@pkgsrc.org>2017-10-17 03:32:28 +0000
commitab96674e5e7bee5d14599e5cd358ea8f2d0527a9 (patch)
tree332e6ea5eb6610de9c188eb7366b131481a309e9 /pkgtools
parent3d2ea617067ae7102bb0d1bcc39975da1ad430d0 (diff)
downloadpkgsrc-ab96674e5e7bee5d14599e5cd358ea8f2d0527a9.tar.gz
Some files are moved. Fix build
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/linechecker.go82
-rw-r--r--pkgtools/pkglint/files/linechecker_test.go43
2 files changed, 0 insertions, 125 deletions
diff --git a/pkgtools/pkglint/files/linechecker.go b/pkgtools/pkglint/files/linechecker.go
deleted file mode 100644
index 6baf7a8609c..00000000000
--- a/pkgtools/pkglint/files/linechecker.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package main
-
-import (
- "fmt"
- "netbsd.org/pkglint/line"
- "netbsd.org/pkglint/regex"
- "netbsd.org/pkglint/trace"
-)
-
-type LineChecker struct {
- Line line.Line
-}
-
-func (ck LineChecker) CheckAbsolutePathname(text string) {
- if trace.Tracing {
- defer trace.Call1(text)()
- }
-
- // In the GNU coding standards, DESTDIR is defined as a (usually
- // empty) prefix that can be used to install files to a different
- // location from what they have been built for. Therefore
- // everything following it is considered an absolute pathname.
- //
- // Another context where absolute pathnames usually appear is in
- // assignments like "bindir=/bin".
- if m, path := match1(text, `(?:^|\$[{(]DESTDIR[)}]|[\w_]+\s*=\s*)(/(?:[^"'\s]|"[^"*]"|'[^']*')*)`); m {
- if matches(path, `^/\w`) {
- checkwordAbsolutePathname(ck.Line, path)
- }
- }
-}
-
-func (ck LineChecker) CheckLength(maxlength int) {
- if len(ck.Line.Text()) > maxlength {
- ck.Line.Warnf("Line too long (should be no more than %d characters).", maxlength)
- Explain(
- "Back in the old time, terminals with 80x25 characters were common.",
- "And this is still the default size of many terminal emulators.",
- "Moderately short lines also make reading easier.")
- }
-}
-
-func (ck LineChecker) CheckValidCharacters(reChar regex.RegexPattern) {
- rest := regex.Compile(reChar).ReplaceAllString(ck.Line.Text(), "")
- if rest != "" {
- uni := ""
- for _, c := range rest {
- uni += fmt.Sprintf(" %U", c)
- }
- ck.Line.Warnf("Line contains invalid characters (%s).", uni[1:])
- }
-}
-
-func (ck LineChecker) CheckTrailingWhitespace() {
- if hasSuffix(ck.Line.Text(), " ") || hasSuffix(ck.Line.Text(), "\t") {
- if !ck.Line.AutofixReplaceRegexp(`\s+\n$`, "\n") {
- ck.Line.Notef("Trailing white-space.")
- Explain(
- "When a line ends with some white-space, that space is in most cases",
- "irrelevant and can be removed.")
- }
- }
-}
-
-func (ck LineChecker) CheckRcsid(prefixRe regex.RegexPattern, suggestedPrefix string) bool {
- if trace.Tracing {
- defer trace.Call(prefixRe, suggestedPrefix)()
- }
-
- if matches(ck.Line.Text(), `^`+prefixRe+`\$`+`NetBSD(?::[^\$]+)?\$$`) {
- return true
- }
-
- if !ck.Line.AutofixInsertBefore(suggestedPrefix + "$" + "NetBSD$") {
- ck.Line.Errorf("Expected %q.", suggestedPrefix+"$"+"NetBSD$")
- Explain(
- "Several files in pkgsrc must contain the CVS Id, so that their",
- "current version can be traced back later from a binary package.",
- "This is to ensure reproducible builds, for example for finding bugs.")
- }
- return false
-}
diff --git a/pkgtools/pkglint/files/linechecker_test.go b/pkgtools/pkglint/files/linechecker_test.go
deleted file mode 100644
index 084b7a877ac..00000000000
--- a/pkgtools/pkglint/files/linechecker_test.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package main
-
-import "gopkg.in/check.v1"
-
-func (s *Suite) Test_LineChecker_CheckAbsolutePathname(c *check.C) {
- s.Init(c)
- ck := LineChecker{NewLine("Makefile", 1, "# dummy", nil)}
-
- ck.CheckAbsolutePathname("bindir=/bin")
- ck.CheckAbsolutePathname("bindir=/../lib")
-
- s.CheckOutputLines(
- "WARN: Makefile:1: Found absolute pathname: /bin")
-}
-
-func (s *Suite) Test_LineChecker_CheckTrailingWhitespace(c *check.C) {
- s.Init(c)
- ck := LineChecker{NewLine("Makefile", 32, "The line must go on ", nil)}
-
- ck.CheckTrailingWhitespace()
-
- s.CheckOutputLines(
- "NOTE: Makefile:32: Trailing white-space.")
-}
-
-func (s *Suite) Test_LineChecker_CheckRcsid(c *check.C) {
- s.Init(c)
- lines := s.NewLines("fname",
- "$"+"NetBSD: dummy $",
- "$"+"NetBSD$",
- "$"+"Id: dummy $",
- "$"+"Id$",
- "$"+"FreeBSD$")
-
- for _, line := range lines {
- LineChecker{line}.CheckRcsid(``, "")
- }
-
- s.CheckOutputLines(
- "ERROR: fname:3: Expected \"$"+"NetBSD$\".",
- "ERROR: fname:4: Expected \"$"+"NetBSD$\".",
- "ERROR: fname:5: Expected \"$"+"NetBSD$\".")
-}