From 3634a7bb931862ada0bc1c4357303d7ce18e7c20 Mon Sep 17 00:00:00 2001 From: Joseph Richey Date: Sun, 11 Feb 2018 20:24:21 -0800 Subject: dep: add dependancies to Gopkg.toml fscrypt directly depends on 5 repositories (8 packages). This change adds those dependancies to Gopkg.toml, so that they can be properly versioned. Note that the golang.org/x repositories do not use semver. --- Gopkg.toml | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'Gopkg.toml') diff --git a/Gopkg.toml b/Gopkg.toml index bd585b3..136d7b4 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,29 +1,24 @@ -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true +# Source dependancies +[[constraint]] + name = "github.com/golang/protobuf" + version = "1.0.0" +[[constraint]] + name = "github.com/pkg/errors" + version = "0.8.0" + +[[constraint]] + name = "github.com/urfave/cli" + version = "1.20.0" + +# golang.org/x/* packages are not versioned +[[constraint]] + name = "golang.org/x/crypto" + branch = "master" + +[[constraint]] + name = "golang.org/x/sys" + branch = "master" [prune] non-go = true -- cgit v1.3 From fff13ea9041a3945e36d5f002c3c0a1e0e93c825 Mon Sep 17 00:00:00 2001 From: Joseph Richey Date: Sun, 11 Feb 2018 20:31:27 -0800 Subject: dep: require tools to be vendored This change ot Gopkg.toml will make it easier to build the linting and formatting tools. Vendoring their source also makes sure that updates to these tools do not break the build. --- Gopkg.toml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Gopkg.toml') diff --git a/Gopkg.toml b/Gopkg.toml index 136d7b4..29da3c7 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,3 +1,12 @@ +# Tools required for generating, liniting, and formatting code +required = [ + "github.com/golang/lint/golint", + "github.com/golang/protobuf/protoc-gen-go", + "golang.org/x/tools/cmd/goimports", + "honnef.co/go/tools/cmd/megacheck", + "github.com/wadey/gocovmerge" +] + # Source dependancies [[constraint]] name = "github.com/golang/protobuf" -- cgit v1.3 From 734f50d8fcb4df4cf611e774123b835f9fc5666b Mon Sep 17 00:00:00 2001 From: Joseph Richey Date: Sun, 11 Feb 2018 20:39:12 -0800 Subject: golint: Use fork that respects vendor directory Ideally, we would just use "golint ./..." to check all our our source files for lint error. However, this does not work because it will include all packages in the vendor directory. The pull request at: https://github.com/golang/lint/pull/325 fixes this issue, so we will use it until the PR has been merged. --- Gopkg.lock | 7 ++- Gopkg.toml | 5 ++ vendor/github.com/golang/lint/golint/golint.go | 5 +- vendor/github.com/golang/lint/lint.go | 87 ++------------------------ 4 files changed, 19 insertions(+), 85 deletions(-) (limited to 'Gopkg.toml') diff --git a/Gopkg.lock b/Gopkg.lock index 2a5953a..d6dd34e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,13 +2,14 @@ [[projects]] - branch = "master" + branch = "lukyth/feature/ignore-vendor" name = "github.com/golang/lint" packages = [ ".", "golint" ] - revision = "e14d9b0f1d332b1420c1ffa32562ad2dc84d645d" + revision = "0dcd199f6e2c9e5fb738b78bfa2170de4c78a25f" + source = "github.com/lukyth/lint" [[projects]] name = "github.com/golang/protobuf" @@ -113,6 +114,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "65c9e40abcc4d3679513c43ba962f87115e94ced6497ac13e9ef5685815c7da8" + inputs-digest = "13bc740ba83539fecd6dd4b7d026fd221077369cb6b170e83d288383d0fde474" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 29da3c7..8336862 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -7,6 +7,11 @@ required = [ "github.com/wadey/gocovmerge" ] +[[constraint]] + name = "github.com/golang/lint" + branch = "lukyth/feature/ignore-vendor" + source = "github.com/lukyth/lint" + # Source dependancies [[constraint]] name = "github.com/golang/protobuf" diff --git a/vendor/github.com/golang/lint/golint/golint.go b/vendor/github.com/golang/lint/golint/golint.go index d8360ad..0088274 100644 --- a/vendor/github.com/golang/lint/golint/golint.go +++ b/vendor/github.com/golang/lint/golint/golint.go @@ -48,9 +48,12 @@ func main() { var dirsRun, filesRun, pkgsRun int var args []string for _, arg := range flag.Args() { - if strings.HasSuffix(arg, "/...") && isDir(arg[:len(arg)-len("/...")]) { + if trimmedArg := strings.TrimSuffix(arg, "/..."); trimmedArg != arg && isDir(trimmedArg) { dirsRun = 1 for _, dirname := range allPackagesInFS(arg) { + if strings.Contains(dirname[len(trimmedArg):], "/vendor/") { + continue + } args = append(args, dirname) } } else if isDir(arg) { diff --git a/vendor/github.com/golang/lint/lint.go b/vendor/github.com/golang/lint/lint.go index 8bb1faa..fb47da0 100644 --- a/vendor/github.com/golang/lint/lint.go +++ b/vendor/github.com/golang/lint/lint.go @@ -199,7 +199,6 @@ func (f *file) lint() { f.lintNames() f.lintVarDecls() f.lintElses() - f.lintIfError() f.lintRanges() f.lintErrorf() f.lintErrors() @@ -1238,7 +1237,7 @@ func (f *file) lintReceiverNames() { name := names[0].Name const ref = styleGuideBase + "#receiver-names" if name == "_" { - f.errorf(n, 1, link(ref), category("naming"), `receiver name should not be an underscore, omit the name if it is unused`) + f.errorf(n, 1, link(ref), category("naming"), `receiver name should not be an underscore`) return true } if name == "this" || name == "self" { @@ -1467,85 +1466,6 @@ func (f *file) lintContextArgs() { }) } -// containsComments returns whether the interval [start, end) contains any -// comments without "// MATCH " prefix. -func (f *file) containsComments(start, end token.Pos) bool { - for _, cgroup := range f.f.Comments { - comments := cgroup.List - if comments[0].Slash >= end { - // All comments starting with this group are after end pos. - return false - } - if comments[len(comments)-1].Slash < start { - // Comments group ends before start pos. - continue - } - for _, c := range comments { - if start <= c.Slash && c.Slash < end && !strings.HasPrefix(c.Text, "// MATCH ") { - return true - } - } - } - return false -} - -func (f *file) lintIfError() { - f.walk(func(node ast.Node) bool { - switch v := node.(type) { - case *ast.BlockStmt: - for i := 0; i < len(v.List)-1; i++ { - // if var := whatever; var != nil { return var } - s, ok := v.List[i].(*ast.IfStmt) - if !ok || s.Body == nil || len(s.Body.List) != 1 || s.Else != nil { - continue - } - assign, ok := s.Init.(*ast.AssignStmt) - if !ok || len(assign.Lhs) != 1 || !(assign.Tok == token.DEFINE || assign.Tok == token.ASSIGN) { - continue - } - id, ok := assign.Lhs[0].(*ast.Ident) - if !ok { - continue - } - expr, ok := s.Cond.(*ast.BinaryExpr) - if !ok || expr.Op != token.NEQ { - continue - } - if lhs, ok := expr.X.(*ast.Ident); !ok || lhs.Name != id.Name { - continue - } - if rhs, ok := expr.Y.(*ast.Ident); !ok || rhs.Name != "nil" { - continue - } - r, ok := s.Body.List[0].(*ast.ReturnStmt) - if !ok || len(r.Results) != 1 { - continue - } - if r, ok := r.Results[0].(*ast.Ident); !ok || r.Name != id.Name { - continue - } - - // return nil - r, ok = v.List[i+1].(*ast.ReturnStmt) - if !ok || len(r.Results) != 1 { - continue - } - if r, ok := r.Results[0].(*ast.Ident); !ok || r.Name != "nil" { - continue - } - - // check if there are any comments explaining the construct, don't emit an error if there are some. - if f.containsComments(s.Pos(), r.Pos()) { - continue - } - - f.errorf(v.List[i], 0.9, "redundant if ...; err != nil check, just return error instead.") - } - } - return true - }) -} - // receiverType returns the named type of the method receiver, sans "*", // or "invalid-type" if fn.Recv is ill formed. func receiverType(fn *ast.FuncDecl) string { @@ -1606,6 +1526,11 @@ func isPkgDot(expr ast.Expr, pkg, name string) bool { return ok && isIdent(sel.X, pkg) && isIdent(sel.Sel, name) } +func isZero(expr ast.Expr) bool { + lit, ok := expr.(*ast.BasicLit) + return ok && lit.Kind == token.INT && lit.Value == "0" +} + func isOne(expr ast.Expr) bool { lit, ok := expr.(*ast.BasicLit) return ok && lit.Kind == token.INT && lit.Value == "1" -- cgit v1.3