{"repo":"alexkohler/nakedret","free":true,"listed":false,"github":"https://github.com/alexkohler/nakedret","clone":"git clone https://github.com/alexkohler/nakedret.git","description":"nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length.","language":"Go","stars":132,"topics":["golang","static-analysis","static-analyzer","static-code-analysis","go"],"license":"MIT","category":"dev-tools","readme_excerpt":"nakedret nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. Installation Install Nakedret via go install: If you have not already added your GOPATH/bin directory to your PATH environment variable then you will need to do so. Windows (cmd): Bash (you can verify a path has been set): Usage Similar to other Go static anaylsis tools (such as golint , go vet ), nakedret can be invoked with one or more filenames, directories, or packages named by its import path. Nakedret also supports the ... wildcard. nakedret [flags] files/directories/packages Currently, the only flag supported is -l, which is an optional numeric flag to specify the maximum length a function can be (in terms of line length). If not specified, it defaults to 5. It can also be run using go vet : Purpose As noted in Go's Code Review comments: Naked returns are okay if the function is a handful of lines. Once it's a medium sized function, be explicit with your return values. Corollary: it's not worth it to name result parameters just because it enables you to use naked returns. Clarity of docs is always more important than saving a line or two in your function. This tool aims to catch naked returns on non-trivial functions. Example Let's take the types package in the Go source as an example: Below is one of the not so intuitive uses of naked returns in types/lookup.go found by nakedret (nakedret will return the line number of the last naked return in th","default_branch":null,"files":null,"tree":[],"storefront":"/r/alexkohler","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/alexkohler/nakedret/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}