{"id":13771082,"url":"https://github.com/alexkohler/nakedret","last_synced_at":"2026-01-16T19:17:32.664Z","repository":{"id":54626218,"uuid":"106192858","full_name":"alexkohler/nakedret","owner":"alexkohler","description":"nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length.","archived":false,"fork":false,"pushed_at":"2025-05-01T01:56:01.000Z","size":1282,"stargazers_count":129,"open_issues_count":1,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-11T03:36:20.750Z","etag":null,"topics":["go","golang","static-analysis","static-analyzer","static-code-analysis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexkohler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-08T16:48:58.000Z","updated_at":"2025-04-07T12:52:42.000Z","dependencies_parsed_at":"2024-03-18T14:48:17.478Z","dependency_job_id":"85bb57a4-e6da-4282-a1c0-1cfa43b6904b","html_url":"https://github.com/alexkohler/nakedret","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/alexkohler/nakedret","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkohler%2Fnakedret","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkohler%2Fnakedret/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkohler%2Fnakedret/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkohler%2Fnakedret/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexkohler","download_url":"https://codeload.github.com/alexkohler/nakedret/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkohler%2Fnakedret/sbom","scorecard":{"id":181928,"data":{"date":"2025-08-11","repo":{"name":"github.com/alexkohler/nakedret","commit":"a81d2cd7bb6338006413dedd81fa7fb7c8b8ce85"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.2,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build-test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":8,"reason":"Found 11/13 approved changesets -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/alexkohler/nakedret/build-test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/alexkohler/nakedret/build-test.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T19:00:03.735Z","repository_id":54626218,"created_at":"2025-08-16T19:00:03.735Z","updated_at":"2025-08-16T19:00:03.735Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28481652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","static-analysis","static-analyzer","static-code-analysis"],"created_at":"2024-08-03T17:00:47.408Z","updated_at":"2026-01-16T19:17:32.648Z","avatar_url":"https://github.com/alexkohler.png","language":"Go","funding_links":[],"categories":["Linters","Programming Languages"],"sub_categories":["Code Complexity"],"readme":"# nakedret\n\nnakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length.\n\n## Installation\nInstall Nakedret via go install:\n\n```cmd\ngo install github.com/alexkohler/nakedret/v2/cmd/nakedret@latest\n```\n\nIf you have not already added your `GOPATH/bin` directory to your `PATH` environment variable then you will need to do so.\n\nWindows (cmd):\n```cmd\nset PATH=%PATH%;C:\\your\\GOPATH\\bin\n```\n\nBash (you can verify a path has been set):\n```Bash\n# Check if nakedret is on PATH\nwhich nakedret\nexport PATH=$PATH:/your/GOPATH/bin #to set path if it does not exist\n```\n\n## Usage\n\nSimilar 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. \n\n    nakedret [flags] files/directories/packages\n\nCurrently, 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.\n\nIt can also be run using `go vet`:\n\n```shell\ngo vet -vettool=$(which nakedret) ./...\n```\n\n## Purpose\n\nAs noted in Go's [Code Review comments](https://github.com/golang/go/wiki/CodeReviewComments#named-result-parameters):\n\n\u003e Naked returns are okay if the function is a handful of lines. Once it's a medium sized function, be explicit with your return \n\u003e 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.\n\nThis tool aims to catch naked returns on non-trivial functions.\n\n## Example\n\nLet's take the `types` package in the Go source as an example:\n\n```Bash\n$ nakedret -l 25 types/\ntypes/check.go:245 checkFiles naked returns on 26 line function \ntypes/typexpr.go:443 collectParams naked returns on 53 line function \ntypes/stmt.go:275 caseTypes naked returns on 27 line function \ntypes/lookup.go:275 MissingMethod naked returns on 39 line function\n```\n\nBelow 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 the function):\n\n\n```Go\nfunc MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool) {\n\t// fast path for common case\n\tif T.Empty() {\n\t\treturn\n\t}\n\n\t// TODO(gri) Consider using method sets here. Might be more efficient.\n\n\tif ityp, _ := V.Underlying().(*Interface); ityp != nil {\n\t\t// TODO(gri) allMethods is sorted - can do this more efficiently\n\t\tfor _, m := range T.allMethods {\n\t\t\t_, obj := lookupMethod(ityp.allMethods, m.pkg, m.name)\n\t\t\tswitch {\n\t\t\tcase obj == nil:\n\t\t\t\tif static {\n\t\t\t\t\treturn m, false\n\t\t\t\t}\n\t\t\tcase !Identical(obj.Type(), m.typ):\n\t\t\t\treturn m, true\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\n\t// A concrete type implements T if it implements all methods of T.\n\tfor _, m := range T.allMethods {\n\t\tobj, _, _ := lookupFieldOrMethod(V, false, m.pkg, m.name)\n\n\t\tf, _ := obj.(*Func)\n\t\tif f == nil {\n\t\t\treturn m, false\n\t\t}\n\n\t\tif !Identical(f.typ, m.typ) {\n\t\t\treturn m, true\n\t\t}\n\t}\n\n\treturn\n}\n```\n\n## TODO\n\n- Unit tests (may require some refactoring to do correctly)\n- supporting toggling of `build.Context.UseAllFiles` may be useful for some. \n- Configuration on whether or not to run on test files\n- Vim quickfix format?\n\n\n## Contributing\n\nPull requests welcome!\n\n\n## Other static analysis tools\n\nIf you've enjoyed nakedret, take a look at my other static anaylsis tools!\n\n- [unimport](https://github.com/alexkohler/unimport) - Finds unnecessary import aliases\n- [prealloc](https://github.com/alexkohler/prealloc) - Finds slice declarations that could potentially be preallocated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexkohler%2Fnakedret","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexkohler%2Fnakedret","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexkohler%2Fnakedret/lists"}