From 376425d51780880d0663b1202289baa7f7aa8337 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 30 Oct 2018 15:37:27 -0700 Subject: [PATCH] refactor: remove URL field from the failure struct --- lint/failure.go | 1 - rule/blank-imports.go | 1 - rule/confusing-naming.go | 2 -- rule/confusing-results.go | 1 - rule/context-as-argument.go | 1 - rule/deep-exit.go | 1 - rule/dot-imports.go | 1 - rule/empty-block.go | 1 - rule/empty-lines.go | 2 -- rule/error-strings.go | 1 - rule/exported.go | 7 ------- rule/get-return.go | 1 - rule/indent-error-flow.go | 1 - rule/line-length-limit.go | 1 - rule/modifies-param.go | 1 - rule/package-comments.go | 4 ---- rule/receiver-naming.go | 3 --- rule/superfluous-else.go | 1 - rule/var-naming.go | 5 ----- 19 files changed, 36 deletions(-) diff --git a/lint/failure.go b/lint/failure.go index 63ffa4e..479b0cb 100644 --- a/lint/failure.go +++ b/lint/failure.go @@ -29,7 +29,6 @@ type Failure struct { Position FailurePosition Node ast.Node `json:"-"` Confidence float64 - URL string // For future use ReplacementLine string } diff --git a/rule/blank-imports.go b/rule/blank-imports.go index 40f362f..0a00e37 100644 --- a/rule/blank-imports.go +++ b/rule/blank-imports.go @@ -67,7 +67,6 @@ func (w lintBlankImports) Visit(_ ast.Node) ast.Visitor { Failure: "a blank import should be only in a main or test package, or have a comment justifying it", Confidence: 1, Category: "imports", - URL: "", }) } } diff --git a/rule/confusing-naming.go b/rule/confusing-naming.go index d1dbaa6..143bb18 100644 --- a/rule/confusing-naming.go +++ b/rule/confusing-naming.go @@ -105,7 +105,6 @@ func checkMethodName(holder string, id *ast.Ident, w *lintConfusingNames) { Confidence: 1, Node: id, Category: "naming", - URL: "#TODO", }) return @@ -161,7 +160,6 @@ func checkStructFields(fields *ast.FieldList, structName string, w *lintConfusin Confidence: 1, Node: id, Category: "naming", - URL: "#TODO", }) } else { bl[normName] = true diff --git a/rule/confusing-results.go b/rule/confusing-results.go index 8a236e4..1d386b3 100644 --- a/rule/confusing-results.go +++ b/rule/confusing-results.go @@ -54,7 +54,6 @@ func (w lintConfusingResults) Visit(n ast.Node) ast.Visitor { w.onFailure(lint.Failure{ Node: n, Confidence: 1, - URL: "#named-result-parameters", Category: "naming", Failure: "unnamed results of the same type may be confusing, consider using named results", }) diff --git a/rule/context-as-argument.go b/rule/context-as-argument.go index 0aee5b0..0ed28a8 100644 --- a/rule/context-as-argument.go +++ b/rule/context-as-argument.go @@ -50,7 +50,6 @@ func (w lintContextArguments) Visit(n ast.Node) ast.Visitor { w.onFailure(lint.Failure{ Node: fn, Category: "arg-order", - URL: "https://golang.org/pkg/context/", Failure: "context.Context should be the first parameter of a function", Confidence: 0.9, }) diff --git a/rule/deep-exit.go b/rule/deep-exit.go index ecf8b44..c286b8d 100644 --- a/rule/deep-exit.go +++ b/rule/deep-exit.go @@ -81,7 +81,6 @@ func (w lintDeepExit) Visit(node ast.Node) ast.Visitor { Confidence: 1, Node: ce, Category: "bad practice", - URL: "#deep-exit", Failure: fmt.Sprintf("calls to %s.%s only in main() or init() functions", pkg, fn), }) } diff --git a/rule/dot-imports.go b/rule/dot-imports.go index 63e03db..78419d7 100644 --- a/rule/dot-imports.go +++ b/rule/dot-imports.go @@ -47,7 +47,6 @@ func (w lintImports) Visit(_ ast.Node) ast.Visitor { Failure: "should not use dot imports", Node: is, Category: "imports", - URL: "#import-dot", }) } } diff --git a/rule/empty-block.go b/rule/empty-block.go index 8d96200..7861394 100644 --- a/rule/empty-block.go +++ b/rule/empty-block.go @@ -59,7 +59,6 @@ func (w lintEmptyBlock) Visit(node ast.Node) ast.Visitor { Confidence: 1, Node: block, Category: "logic", - URL: "#empty-block", Failure: "this block is empty, you can remove it", }) } diff --git a/rule/empty-lines.go b/rule/empty-lines.go index 37ec2a8..61d9281 100644 --- a/rule/empty-lines.go +++ b/rule/empty-lines.go @@ -64,7 +64,6 @@ func (w lintEmptyLines) checkStart(block *ast.BlockStmt) { Confidence: 1, Node: block, Category: "style", - URL: "#empty-lines", Failure: "extra empty line at the start of a block", }) } @@ -88,7 +87,6 @@ func (w lintEmptyLines) checkEnd(block *ast.BlockStmt) { Confidence: 1, Node: lastNode, Category: "style", - URL: "#empty-lines", Failure: "extra empty line at the end of a block", }) } diff --git a/rule/error-strings.go b/rule/error-strings.go index 699de12..b8a5b7e 100644 --- a/rule/error-strings.go +++ b/rule/error-strings.go @@ -69,7 +69,6 @@ func (w lintErrorStrings) Visit(n ast.Node) ast.Visitor { w.onFailure(lint.Failure{ Node: str, Confidence: conf, - URL: "#error-strings", Category: "errors", Failure: "error strings should not be capitalized or end with punctuation or a newline", }) diff --git a/rule/exported.go b/rule/exported.go index 08a1aae..714acf6 100644 --- a/rule/exported.go +++ b/rule/exported.go @@ -80,7 +80,6 @@ func (w *lintExported) lintFuncDoc(fn *ast.FuncDecl) { w.onFailure(lint.Failure{ Node: fn, Confidence: 1, - URL: "#doc-comments", Category: "comments", Failure: fmt.Sprintf("exported %s %s should have comment or be unexported", kind, name), }) @@ -92,7 +91,6 @@ func (w *lintExported) lintFuncDoc(fn *ast.FuncDecl) { w.onFailure(lint.Failure{ Node: fn.Doc, Confidence: 0.8, - URL: "#doc-comments", Category: "comments", Failure: fmt.Sprintf(`comment on exported %s %s should be of the form "%s..."`, kind, name, prefix), }) @@ -123,7 +121,6 @@ func (w *lintExported) checkStutter(id *ast.Ident, thing string) { w.onFailure(lint.Failure{ Node: id, Confidence: 0.8, - URL: "#package-names", Category: "naming", Failure: fmt.Sprintf("%s name will be used as %s.%s by other packages, and that stutters; consider calling this %s", thing, pkg, name, rem), }) @@ -138,7 +135,6 @@ func (w *lintExported) lintTypeDoc(t *ast.TypeSpec, doc *ast.CommentGroup) { w.onFailure(lint.Failure{ Node: t, Confidence: 1, - URL: "#doc-comments", Category: "comments", Failure: fmt.Sprintf("exported type %v should have comment or be unexported", t.Name), }) @@ -160,7 +156,6 @@ func (w *lintExported) lintTypeDoc(t *ast.TypeSpec, doc *ast.CommentGroup) { w.onFailure(lint.Failure{ Node: doc, Confidence: 1, - URL: "#doc-comments", Category: "comments", Failure: fmt.Sprintf(`comment on exported type %v should be of the form "%v ..." (with optional leading article)`, t.Name, t.Name), }) @@ -205,7 +200,6 @@ func (w *lintExported) lintValueSpecDoc(vs *ast.ValueSpec, gd *ast.GenDecl, genD w.onFailure(lint.Failure{ Confidence: 1, Node: vs, - URL: "#doc-comments", Category: "comments", Failure: fmt.Sprintf("exported %s %s should have comment%s or be unexported", kind, name, block), }) @@ -227,7 +221,6 @@ func (w *lintExported) lintValueSpecDoc(vs *ast.ValueSpec, gd *ast.GenDecl, genD w.onFailure(lint.Failure{ Confidence: 1, Node: doc, - URL: "#doc-comments", Category: "comments", Failure: fmt.Sprintf(`comment on exported %s %s should be of the form "%s..."`, kind, name, prefix), }) diff --git a/rule/get-return.go b/rule/get-return.go index dce0f5b..494ab66 100644 --- a/rule/get-return.go +++ b/rule/get-return.go @@ -62,7 +62,6 @@ func (w lintReturnRule) Visit(node ast.Node) ast.Visitor { Confidence: 0.8, Node: fd, Category: "logic", - URL: "#get-return", Failure: fmt.Sprintf("function '%s' seems to be a getter but it does not return any result", fd.Name.Name), }) } diff --git a/rule/indent-error-flow.go b/rule/indent-error-flow.go index 848273e..4c9799b 100644 --- a/rule/indent-error-flow.go +++ b/rule/indent-error-flow.go @@ -71,7 +71,6 @@ func (w lintElse) Visit(node ast.Node) ast.Visitor { Confidence: 1, Node: ifStmt.Else, Category: "indent", - URL: "#indent-error-flow", Failure: "if block ends with a return statement, so drop this else and outdent its block" + extra, }) } diff --git a/rule/line-length-limit.go b/rule/line-length-limit.go index 06a7050..5ee0570 100644 --- a/rule/line-length-limit.go +++ b/rule/line-length-limit.go @@ -77,7 +77,6 @@ func (r lintLineLengthNum) check() { }, Confidence: 1, Failure: fmt.Sprintf("line is %d characters, out of limit %d", c, r.max), - URL: "", }) } l++ diff --git a/rule/modifies-param.go b/rule/modifies-param.go index af9d3ab..e9f1b44 100644 --- a/rule/modifies-param.go +++ b/rule/modifies-param.go @@ -70,7 +70,6 @@ func checkParam(id *ast.Ident, w *lintModifiesParamRule) { Confidence: 0.5, // confidence is low because of shadow variables Node: id, Category: "bad practice", - URL: "#modifies-parameter", Failure: fmt.Sprintf("parameter '%s' seems to be modified", id), }) } diff --git a/rule/package-comments.go b/rule/package-comments.go index 15729ab..00fc5bb 100644 --- a/rule/package-comments.go +++ b/rule/package-comments.go @@ -84,7 +84,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { }, Confidence: 0.9, Failure: "package comment is detached; there should be no blank lines between it and the package statement", - URL: ref, }) return nil } @@ -96,7 +95,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { Node: l.fileAst, Confidence: 0.2, Failure: "should have a package comment, unless it's in another file for this package", - URL: ref, }) return nil } @@ -107,7 +105,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { Node: l.fileAst.Doc, Confidence: 1, Failure: "package comment should not have leading space", - URL: ref, }) s = ts } @@ -118,7 +115,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { Node: l.fileAst.Doc, Confidence: 1, Failure: fmt.Sprintf(`package comment should be of the form "%s..."`, prefix), - URL: ref, }) } return nil diff --git a/rule/receiver-naming.go b/rule/receiver-naming.go index c07bc1c..589d5f0 100644 --- a/rule/receiver-naming.go +++ b/rule/receiver-naming.go @@ -52,7 +52,6 @@ func (w lintReceiverName) Visit(n ast.Node) ast.Visitor { w.onFailure(lint.Failure{ Node: n, Confidence: 1, - URL: ref, Category: "naming", Failure: "receiver name should not be an underscore, omit the name if it is unused", }) @@ -62,7 +61,6 @@ func (w lintReceiverName) Visit(n ast.Node) ast.Visitor { w.onFailure(lint.Failure{ Node: n, Confidence: 1, - URL: ref, Category: "naming", Failure: `receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"`, }) @@ -73,7 +71,6 @@ func (w lintReceiverName) Visit(n ast.Node) ast.Visitor { w.onFailure(lint.Failure{ Node: n, Confidence: 1, - URL: ref, Category: "naming", Failure: fmt.Sprintf("receiver name %s should be consistent with previous receiver name %s for %s", name, prev, recv), }) diff --git a/rule/superfluous-else.go b/rule/superfluous-else.go index 575c97e..c29be9e 100644 --- a/rule/superfluous-else.go +++ b/rule/superfluous-else.go @@ -109,7 +109,6 @@ func newFailure(node ast.Node, msg string) lint.Failure { Confidence: 1, Node: node, Category: "indent", - URL: "#indent-error-flow", Failure: msg, } } diff --git a/rule/var-naming.go b/rule/var-naming.go index c49c9f1..768f65b 100644 --- a/rule/var-naming.go +++ b/rule/var-naming.go @@ -45,7 +45,6 @@ func (r *VarNamingRule) Apply(file *lint.File, arguments lint.Arguments) []lint. Confidence: 1, Node: walker.fileAst, Category: "naming", - URL: "http://golang.org/doc/effective_go.html#package-names", }) } @@ -85,7 +84,6 @@ func check(id *ast.Ident, thing string, w *lintNames) { Confidence: 0.8, Node: id, Category: "naming", - URL: "#mixed-caps", }) return } @@ -96,7 +94,6 @@ func check(id *ast.Ident, thing string, w *lintNames) { Confidence: 0.8, Node: id, Category: "naming", - URL: "#mixed-caps", }) } @@ -111,7 +108,6 @@ func check(id *ast.Ident, thing string, w *lintNames) { Confidence: 0.9, Node: id, Category: "naming", - URL: "http://golang.org/doc/effective_go.html#mixed-caps", }) return } @@ -120,7 +116,6 @@ func check(id *ast.Ident, thing string, w *lintNames) { Confidence: 0.8, Node: id, Category: "naming", - URL: "#initialisms", }) }