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 | ||||
| 	Node       ast.Node `json:"-"` | ||||
| 	Confidence float64 | ||||
| 	URL        string | ||||
| 	// For future use | ||||
| 	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", | ||||
| 				Confidence: 1, | ||||
| 				Category:   "imports", | ||||
| 				URL:        "", | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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", | ||||
| 			}) | ||||
|   | ||||
| @@ -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, | ||||
| 			}) | ||||
|   | ||||
| @@ -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), | ||||
| 		}) | ||||
| 	} | ||||
|   | ||||
| @@ -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", | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
| @@ -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", | ||||
| 		}) | ||||
| 	} | ||||
|   | ||||
| @@ -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", | ||||
| 		}) | ||||
| 	} | ||||
|   | ||||
| @@ -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", | ||||
| 	}) | ||||
|   | ||||
| @@ -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), | ||||
| 		}) | ||||
|   | ||||
| @@ -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), | ||||
| 		}) | ||||
| 	} | ||||
|   | ||||
| @@ -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, | ||||
| 		}) | ||||
| 	} | ||||
|   | ||||
| @@ -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++ | ||||
|   | ||||
| @@ -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), | ||||
| 		}) | ||||
| 	} | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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), | ||||
| 		}) | ||||
|   | ||||
| @@ -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, | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -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", | ||||
| 	}) | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user