提交 73067fd2 编写于 作者: Z Zach 提交者: Felix Lange

buld: enable goconst linter (#15566)

上级 e37f7be9
...@@ -323,7 +323,15 @@ func doLint(cmdline []string) { ...@@ -323,7 +323,15 @@ func doLint(cmdline []string) {
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install") build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install")
// Run fast linters batched together // Run fast linters batched together
configs := []string{"--vendor", "--disable-all", "--enable=vet", "--enable=gofmt", "--enable=misspell"} configs := []string{
"--vendor",
"--disable-all",
"--enable=vet",
"--enable=gofmt",
"--enable=misspell",
"--enable=goconst",
"--min-occurrences=6", // for goconst
}
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...) build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
// Run slow linters one by one // Run slow linters one by one
......
...@@ -30,6 +30,8 @@ import ( ...@@ -30,6 +30,8 @@ import (
"gopkg.in/urfave/cli.v1" "gopkg.in/urfave/cli.v1"
) )
const bzzManifestJSON = "application/bzz-manifest+json"
func add(ctx *cli.Context) { func add(ctx *cli.Context) {
args := ctx.Args() args := ctx.Args()
if len(args) < 3 { if len(args) < 3 {
...@@ -145,7 +147,7 @@ func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) strin ...@@ -145,7 +147,7 @@ func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) strin
if path == entry.Path { if path == entry.Path {
utils.Fatalf("Path %s already present, not adding anything", path) utils.Fatalf("Path %s already present, not adding anything", path)
} else { } else {
if entry.ContentType == "application/bzz-manifest+json" { if entry.ContentType == bzzManifestJSON {
prfxlen := strings.HasPrefix(path, entry.Path) prfxlen := strings.HasPrefix(path, entry.Path)
if prfxlen && len(path) > len(longestPathEntry.Path) { if prfxlen && len(path) > len(longestPathEntry.Path) {
longestPathEntry = entry longestPathEntry = entry
...@@ -207,7 +209,7 @@ func updateEntryInManifest(ctx *cli.Context, mhash, path, hash, ctype string) st ...@@ -207,7 +209,7 @@ func updateEntryInManifest(ctx *cli.Context, mhash, path, hash, ctype string) st
if path == entry.Path { if path == entry.Path {
newEntry = entry newEntry = entry
} else { } else {
if entry.ContentType == "application/bzz-manifest+json" { if entry.ContentType == bzzManifestJSON {
prfxlen := strings.HasPrefix(path, entry.Path) prfxlen := strings.HasPrefix(path, entry.Path)
if prfxlen && len(path) > len(longestPathEntry.Path) { if prfxlen && len(path) > len(longestPathEntry.Path) {
longestPathEntry = entry longestPathEntry = entry
...@@ -281,7 +283,7 @@ func removeEntryFromManifest(ctx *cli.Context, mhash, path string) string { ...@@ -281,7 +283,7 @@ func removeEntryFromManifest(ctx *cli.Context, mhash, path string) string {
if path == entry.Path { if path == entry.Path {
entryToRemove = entry entryToRemove = entry
} else { } else {
if entry.ContentType == "application/bzz-manifest+json" { if entry.ContentType == bzzManifestJSON {
prfxlen := strings.HasPrefix(path, entry.Path) prfxlen := strings.HasPrefix(path, entry.Path)
if prfxlen && len(path) > len(longestPathEntry.Path) { if prfxlen && len(path) > len(longestPathEntry.Path) {
longestPathEntry = entry longestPathEntry = entry
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册