mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	refactor: remove URL field from the failure struct
This commit is contained in:
		| @@ -29,7 +29,6 @@ type Failure struct { | |||||||
| 	Position   FailurePosition | 	Position   FailurePosition | ||||||
| 	Node       ast.Node `json:"-"` | 	Node       ast.Node `json:"-"` | ||||||
| 	Confidence float64 | 	Confidence float64 | ||||||
| 	URL        string |  | ||||||
| 	// For future use | 	// For future use | ||||||
| 	ReplacementLine string | 	ReplacementLine string | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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", | 				Failure:    "a blank import should be only in a main or test package, or have a comment justifying it", | ||||||
| 				Confidence: 1, | 				Confidence: 1, | ||||||
| 				Category:   "imports", | 				Category:   "imports", | ||||||
| 				URL:        "", |  | ||||||
| 			}) | 			}) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -105,7 +105,6 @@ func checkMethodName(holder string, id *ast.Ident, w *lintConfusingNames) { | |||||||
| 				Confidence: 1, | 				Confidence: 1, | ||||||
| 				Node:       id, | 				Node:       id, | ||||||
| 				Category:   "naming", | 				Category:   "naming", | ||||||
| 				URL:        "#TODO", |  | ||||||
| 			}) | 			}) | ||||||
|  |  | ||||||
| 			return | 			return | ||||||
| @@ -161,7 +160,6 @@ func checkStructFields(fields *ast.FieldList, structName string, w *lintConfusin | |||||||
| 					Confidence: 1, | 					Confidence: 1, | ||||||
| 					Node:       id, | 					Node:       id, | ||||||
| 					Category:   "naming", | 					Category:   "naming", | ||||||
| 					URL:        "#TODO", |  | ||||||
| 				}) | 				}) | ||||||
| 			} else { | 			} else { | ||||||
| 				bl[normName] = true | 				bl[normName] = true | ||||||
|   | |||||||
| @@ -54,7 +54,6 @@ func (w lintConfusingResults) Visit(n ast.Node) ast.Visitor { | |||||||
| 			w.onFailure(lint.Failure{ | 			w.onFailure(lint.Failure{ | ||||||
| 				Node:       n, | 				Node:       n, | ||||||
| 				Confidence: 1, | 				Confidence: 1, | ||||||
| 				URL:        "#named-result-parameters", |  | ||||||
| 				Category:   "naming", | 				Category:   "naming", | ||||||
| 				Failure:    "unnamed results of the same type may be confusing, consider using named results", | 				Failure:    "unnamed results of the same type may be confusing, consider using named results", | ||||||
| 			}) | 			}) | ||||||
|   | |||||||
| @@ -50,7 +50,6 @@ func (w lintContextArguments) Visit(n ast.Node) ast.Visitor { | |||||||
| 			w.onFailure(lint.Failure{ | 			w.onFailure(lint.Failure{ | ||||||
| 				Node:       fn, | 				Node:       fn, | ||||||
| 				Category:   "arg-order", | 				Category:   "arg-order", | ||||||
| 				URL:        "https://golang.org/pkg/context/", |  | ||||||
| 				Failure:    "context.Context should be the first parameter of a function", | 				Failure:    "context.Context should be the first parameter of a function", | ||||||
| 				Confidence: 0.9, | 				Confidence: 0.9, | ||||||
| 			}) | 			}) | ||||||
|   | |||||||
| @@ -81,7 +81,6 @@ func (w lintDeepExit) Visit(node ast.Node) ast.Visitor { | |||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       ce, | 			Node:       ce, | ||||||
| 			Category:   "bad practice", | 			Category:   "bad practice", | ||||||
| 			URL:        "#deep-exit", |  | ||||||
| 			Failure:    fmt.Sprintf("calls to %s.%s only in main() or init() functions", pkg, fn), | 			Failure:    fmt.Sprintf("calls to %s.%s only in main() or init() functions", pkg, fn), | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -47,7 +47,6 @@ func (w lintImports) Visit(_ ast.Node) ast.Visitor { | |||||||
| 				Failure:    "should not use dot imports", | 				Failure:    "should not use dot imports", | ||||||
| 				Node:       is, | 				Node:       is, | ||||||
| 				Category:   "imports", | 				Category:   "imports", | ||||||
| 				URL:        "#import-dot", |  | ||||||
| 			}) | 			}) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -59,7 +59,6 @@ func (w lintEmptyBlock) Visit(node ast.Node) ast.Visitor { | |||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       block, | 			Node:       block, | ||||||
| 			Category:   "logic", | 			Category:   "logic", | ||||||
| 			URL:        "#empty-block", |  | ||||||
| 			Failure:    "this block is empty, you can remove it", | 			Failure:    "this block is empty, you can remove it", | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -64,7 +64,6 @@ func (w lintEmptyLines) checkStart(block *ast.BlockStmt) { | |||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       block, | 			Node:       block, | ||||||
| 			Category:   "style", | 			Category:   "style", | ||||||
| 			URL:        "#empty-lines", |  | ||||||
| 			Failure:    "extra empty line at the start of a block", | 			Failure:    "extra empty line at the start of a block", | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| @@ -88,7 +87,6 @@ func (w lintEmptyLines) checkEnd(block *ast.BlockStmt) { | |||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       lastNode, | 			Node:       lastNode, | ||||||
| 			Category:   "style", | 			Category:   "style", | ||||||
| 			URL:        "#empty-lines", |  | ||||||
| 			Failure:    "extra empty line at the end of a block", | 			Failure:    "extra empty line at the end of a block", | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -69,7 +69,6 @@ func (w lintErrorStrings) Visit(n ast.Node) ast.Visitor { | |||||||
| 	w.onFailure(lint.Failure{ | 	w.onFailure(lint.Failure{ | ||||||
| 		Node:       str, | 		Node:       str, | ||||||
| 		Confidence: conf, | 		Confidence: conf, | ||||||
| 		URL:        "#error-strings", |  | ||||||
| 		Category:   "errors", | 		Category:   "errors", | ||||||
| 		Failure:    "error strings should not be capitalized or end with punctuation or a newline", | 		Failure:    "error strings should not be capitalized or end with punctuation or a newline", | ||||||
| 	}) | 	}) | ||||||
|   | |||||||
| @@ -80,7 +80,6 @@ func (w *lintExported) lintFuncDoc(fn *ast.FuncDecl) { | |||||||
| 		w.onFailure(lint.Failure{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       fn, | 			Node:       fn, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			URL:        "#doc-comments", |  | ||||||
| 			Category:   "comments", | 			Category:   "comments", | ||||||
| 			Failure:    fmt.Sprintf("exported %s %s should have comment or be unexported", kind, name), | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       fn.Doc, | 			Node:       fn.Doc, | ||||||
| 			Confidence: 0.8, | 			Confidence: 0.8, | ||||||
| 			URL:        "#doc-comments", |  | ||||||
| 			Category:   "comments", | 			Category:   "comments", | ||||||
| 			Failure:    fmt.Sprintf(`comment on exported %s %s should be of the form "%s..."`, kind, name, prefix), | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       id, | 			Node:       id, | ||||||
| 			Confidence: 0.8, | 			Confidence: 0.8, | ||||||
| 			URL:        "#package-names", |  | ||||||
| 			Category:   "naming", | 			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), | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       t, | 			Node:       t, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			URL:        "#doc-comments", |  | ||||||
| 			Category:   "comments", | 			Category:   "comments", | ||||||
| 			Failure:    fmt.Sprintf("exported type %v should have comment or be unexported", t.Name), | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       doc, | 			Node:       doc, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			URL:        "#doc-comments", |  | ||||||
| 			Category:   "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), | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       vs, | 			Node:       vs, | ||||||
| 			URL:        "#doc-comments", |  | ||||||
| 			Category:   "comments", | 			Category:   "comments", | ||||||
| 			Failure:    fmt.Sprintf("exported %s %s should have comment%s or be unexported", kind, name, block), | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       doc, | 			Node:       doc, | ||||||
| 			URL:        "#doc-comments", |  | ||||||
| 			Category:   "comments", | 			Category:   "comments", | ||||||
| 			Failure:    fmt.Sprintf(`comment on exported %s %s should be of the form "%s..."`, kind, name, prefix), | 			Failure:    fmt.Sprintf(`comment on exported %s %s should be of the form "%s..."`, kind, name, prefix), | ||||||
| 		}) | 		}) | ||||||
|   | |||||||
| @@ -62,7 +62,6 @@ func (w lintReturnRule) Visit(node ast.Node) ast.Visitor { | |||||||
| 			Confidence: 0.8, | 			Confidence: 0.8, | ||||||
| 			Node:       fd, | 			Node:       fd, | ||||||
| 			Category:   "logic", | 			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), | 			Failure:    fmt.Sprintf("function '%s' seems to be a getter but it does not return any result", fd.Name.Name), | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -71,7 +71,6 @@ func (w lintElse) Visit(node ast.Node) ast.Visitor { | |||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       ifStmt.Else, | 			Node:       ifStmt.Else, | ||||||
| 			Category:   "indent", | 			Category:   "indent", | ||||||
| 			URL:        "#indent-error-flow", |  | ||||||
| 			Failure:    "if block ends with a return statement, so drop this else and outdent its block" + extra, | 			Failure:    "if block ends with a return statement, so drop this else and outdent its block" + extra, | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -77,7 +77,6 @@ func (r lintLineLengthNum) check() { | |||||||
| 				}, | 				}, | ||||||
| 				Confidence: 1, | 				Confidence: 1, | ||||||
| 				Failure:    fmt.Sprintf("line is %d characters, out of limit %d", c, r.max), | 				Failure:    fmt.Sprintf("line is %d characters, out of limit %d", c, r.max), | ||||||
| 				URL:        "", |  | ||||||
| 			}) | 			}) | ||||||
| 		} | 		} | ||||||
| 		l++ | 		l++ | ||||||
|   | |||||||
| @@ -70,7 +70,6 @@ func checkParam(id *ast.Ident, w *lintModifiesParamRule) { | |||||||
| 			Confidence: 0.5, // confidence is low because of shadow variables | 			Confidence: 0.5, // confidence is low because of shadow variables | ||||||
| 			Node:       id, | 			Node:       id, | ||||||
| 			Category:   "bad practice", | 			Category:   "bad practice", | ||||||
| 			URL:        "#modifies-parameter", |  | ||||||
| 			Failure:    fmt.Sprintf("parameter '%s' seems to be modified", id), | 			Failure:    fmt.Sprintf("parameter '%s' seems to be modified", id), | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -84,7 +84,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { | |||||||
| 				}, | 				}, | ||||||
| 				Confidence: 0.9, | 				Confidence: 0.9, | ||||||
| 				Failure:    "package comment is detached; there should be no blank lines between it and the package statement", | 				Failure:    "package comment is detached; there should be no blank lines between it and the package statement", | ||||||
| 				URL:        ref, |  | ||||||
| 			}) | 			}) | ||||||
| 			return nil | 			return nil | ||||||
| 		} | 		} | ||||||
| @@ -96,7 +95,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { | |||||||
| 			Node:       l.fileAst, | 			Node:       l.fileAst, | ||||||
| 			Confidence: 0.2, | 			Confidence: 0.2, | ||||||
| 			Failure:    "should have a package comment, unless it's in another file for this package", | 			Failure:    "should have a package comment, unless it's in another file for this package", | ||||||
| 			URL:        ref, |  | ||||||
| 		}) | 		}) | ||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
| @@ -107,7 +105,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { | |||||||
| 			Node:       l.fileAst.Doc, | 			Node:       l.fileAst.Doc, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Failure:    "package comment should not have leading space", | 			Failure:    "package comment should not have leading space", | ||||||
| 			URL:        ref, |  | ||||||
| 		}) | 		}) | ||||||
| 		s = ts | 		s = ts | ||||||
| 	} | 	} | ||||||
| @@ -118,7 +115,6 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor { | |||||||
| 			Node:       l.fileAst.Doc, | 			Node:       l.fileAst.Doc, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Failure:    fmt.Sprintf(`package comment should be of the form "%s..."`, prefix), | 			Failure:    fmt.Sprintf(`package comment should be of the form "%s..."`, prefix), | ||||||
| 			URL:        ref, |  | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
|   | |||||||
| @@ -52,7 +52,6 @@ func (w lintReceiverName) Visit(n ast.Node) ast.Visitor { | |||||||
| 		w.onFailure(lint.Failure{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       n, | 			Node:       n, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			URL:        ref, |  | ||||||
| 			Category:   "naming", | 			Category:   "naming", | ||||||
| 			Failure:    "receiver name should not be an underscore, omit the name if it is unused", | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       n, | 			Node:       n, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			URL:        ref, |  | ||||||
| 			Category:   "naming", | 			Category:   "naming", | ||||||
| 			Failure:    `receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"`, | 			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{ | 		w.onFailure(lint.Failure{ | ||||||
| 			Node:       n, | 			Node:       n, | ||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			URL:        ref, |  | ||||||
| 			Category:   "naming", | 			Category:   "naming", | ||||||
| 			Failure:    fmt.Sprintf("receiver name %s should be consistent with previous receiver name %s for %s", name, prev, recv), | 			Failure:    fmt.Sprintf("receiver name %s should be consistent with previous receiver name %s for %s", name, prev, recv), | ||||||
| 		}) | 		}) | ||||||
|   | |||||||
| @@ -109,7 +109,6 @@ func newFailure(node ast.Node, msg string) lint.Failure { | |||||||
| 		Confidence: 1, | 		Confidence: 1, | ||||||
| 		Node:       node, | 		Node:       node, | ||||||
| 		Category:   "indent", | 		Category:   "indent", | ||||||
| 		URL:        "#indent-error-flow", |  | ||||||
| 		Failure:    msg, | 		Failure:    msg, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -45,7 +45,6 @@ func (r *VarNamingRule) Apply(file *lint.File, arguments lint.Arguments) []lint. | |||||||
| 			Confidence: 1, | 			Confidence: 1, | ||||||
| 			Node:       walker.fileAst, | 			Node:       walker.fileAst, | ||||||
| 			Category:   "naming", | 			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, | 			Confidence: 0.8, | ||||||
| 			Node:       id, | 			Node:       id, | ||||||
| 			Category:   "naming", | 			Category:   "naming", | ||||||
| 			URL:        "#mixed-caps", |  | ||||||
| 		}) | 		}) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| @@ -96,7 +94,6 @@ func check(id *ast.Ident, thing string, w *lintNames) { | |||||||
| 			Confidence: 0.8, | 			Confidence: 0.8, | ||||||
| 			Node:       id, | 			Node:       id, | ||||||
| 			Category:   "naming", | 			Category:   "naming", | ||||||
| 			URL:        "#mixed-caps", |  | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -111,7 +108,6 @@ func check(id *ast.Ident, thing string, w *lintNames) { | |||||||
| 			Confidence: 0.9, | 			Confidence: 0.9, | ||||||
| 			Node:       id, | 			Node:       id, | ||||||
| 			Category:   "naming", | 			Category:   "naming", | ||||||
| 			URL:        "http://golang.org/doc/effective_go.html#mixed-caps", |  | ||||||
| 		}) | 		}) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| @@ -120,7 +116,6 @@ func check(id *ast.Ident, thing string, w *lintNames) { | |||||||
| 		Confidence: 0.8, | 		Confidence: 0.8, | ||||||
| 		Node:       id, | 		Node:       id, | ||||||
| 		Category:   "naming", | 		Category:   "naming", | ||||||
| 		URL:        "#initialisms", |  | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user