Skip to content

Commit 73067fd

Browse files
zramsayfjl
authored andcommitted
buld: enable goconst linter (#15566)
1 parent e37f7be commit 73067fd

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎build/ci.go‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,15 @@ func doLint(cmdline []string) {
323323
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install")
324324

325325
// Run fast linters batched together
326-
configs := []string{"--vendor", "--disable-all", "--enable=vet", "--enable=gofmt", "--enable=misspell"}
326+
configs := []string{
327+
"--vendor",
328+
"--disable-all",
329+
"--enable=vet",
330+
"--enable=gofmt",
331+
"--enable=misspell",
332+
"--enable=goconst",
333+
"--min-occurrences=6", // for goconst
334+
}
327335
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
328336

329337
// Run slow linters one by one

‎cmd/swarm/manifest.go‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
"gopkg.in/urfave/cli.v1"
3131
)
3232

33+
const bzzManifestJSON = "application/bzz-manifest+json"
34+
3335
func add(ctx *cli.Context) {
3436
args := ctx.Args()
3537
if len(args) < 3 {
@@ -145,7 +147,7 @@ func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) strin
145147
if path == entry.Path {
146148
utils.Fatalf("Path %s already present, not adding anything", path)
147149
} else {
148-
if entry.ContentType == "application/bzz-manifest+json" {
150+
if entry.ContentType == bzzManifestJSON {
149151
prfxlen := strings.HasPrefix(path, entry.Path)
150152
if prfxlen && len(path) > len(longestPathEntry.Path) {
151153
longestPathEntry = entry
@@ -207,7 +209,7 @@ func updateEntryInManifest(ctx *cli.Context, mhash, path, hash, ctype string) st
207209
if path == entry.Path {
208210
newEntry = entry
209211
} else {
210-
if entry.ContentType == "application/bzz-manifest+json" {
212+
if entry.ContentType == bzzManifestJSON {
211213
prfxlen := strings.HasPrefix(path, entry.Path)
212214
if prfxlen && len(path) > len(longestPathEntry.Path) {
213215
longestPathEntry = entry
@@ -281,7 +283,7 @@ func removeEntryFromManifest(ctx *cli.Context, mhash, path string) string {
281283
if path == entry.Path {
282284
entryToRemove = entry
283285
} else {
284-
if entry.ContentType == "application/bzz-manifest+json" {
286+
if entry.ContentType == bzzManifestJSON {
285287
prfxlen := strings.HasPrefix(path, entry.Path)
286288
if prfxlen && len(path) > len(longestPathEntry.Path) {
287289
longestPathEntry = entry

0 commit comments

Comments
 (0)