{"id":16477766,"url":"https://github.com/abirdcfly/dupword","last_synced_at":"2025-04-04T20:15:48.241Z","repository":{"id":58007262,"uuid":"527149357","full_name":"Abirdcfly/dupword","owner":"Abirdcfly","description":"A linter that checks for duplicate words in the source code (usually miswritten)","archived":false,"fork":false,"pushed_at":"2025-03-05T21:18:41.000Z","size":741,"stargazers_count":14,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T21:04:32.678Z","etag":null,"topics":["go","golang","golint","linter"],"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/Abirdcfly.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}},"created_at":"2022-08-21T08:37:02.000Z","updated_at":"2025-03-26T02:04:17.000Z","dependencies_parsed_at":"2024-04-08T20:10:25.061Z","dependency_job_id":"a81ab37f-6a28-4ce5-96cc-e20f048e5acb","html_url":"https://github.com/Abirdcfly/dupword","commit_stats":{"total_commits":72,"total_committers":6,"mean_commits":12.0,"dds":"0.45833333333333337","last_synced_commit":"8fecb81c7b9085c25678e8a16ecb0385a178daef"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abirdcfly%2Fdupword","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abirdcfly%2Fdupword/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abirdcfly%2Fdupword/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abirdcfly%2Fdupword/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Abirdcfly","download_url":"https://codeload.github.com/Abirdcfly/dupword/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242681,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","golint","linter"],"created_at":"2024-10-11T12:46:54.010Z","updated_at":"2025-04-04T20:15:48.213Z","avatar_url":"https://github.com/Abirdcfly.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dupword\n\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/Abirdcfly/dupword?style=flat-square)\n[![GoDoc](https://godoc.org/github.com/Abirdcfly/dupword?status.svg)](https://pkg.go.dev/github.com/Abirdcfly/dupword)\n[![Actions Status](https://github.com/Abirdcfly/dupword/actions/workflows/lint.yml/badge.svg)](https://github.com/Abirdcfly/dupword/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Abirdcfly/dupword)](https://goreportcard.com/report/github.com/Abirdcfly/dupword)\n\nA linter that checks for duplicate words in the source code (usually miswritten)\n\nExamples in real code and related issues can be viewed in [dupword#3](https://github.com/Abirdcfly/dupword/issues/3)\n\n## example\n\n1. Repeated words appear on two adjacent lines [commit](https://github.com/golang/go/commit/d8f90ce0f8119bf593efb6fb91825de5b61fcda7)\n\n```diff\n--- a/src/cmd/compile/internal/ssa/schedule.go\n+++ b/src/cmd/compile/internal/ssa/schedule.go\n@@ -179,7 +179,7 @@ func schedule(f *Func) {\n \t\t\t\t\t// scored CarryChainTail (and prove w is not a tail).\n \t\t\t\t\tscore[w.ID] = ScoreFlags\n \t\t\t\t}\n-\t\t\t\t// Verify v has not been scored. If v has not been visited, v may be the\n+\t\t\t\t// Verify v has not been scored. If v has not been visited, v may be\n \t\t\t\t// the final (tail) operation in a carry chain. If v is not, v will be\n \t\t\t\t// rescored above when v's carry-using op is scored. When scoring is done,\n \t\t\t\t// only tail operations will retain the CarryChainTail score.\n```\n\n2. Repeated words appearing on the same line [commit](https://github.com/golang/go/commit/48da729e8468b630ee003ac51cbaac595d53bec8)\n\n```diff\n--- a/src/net/http/cookiejar/jar.go\n+++ b/src/net/http/cookiejar/jar.go\n@@ -465,7 +465,7 @@ func (j *Jar) domainAndType(host, domain string) (string, bool, error) {\n \t\t// dot in the domain-attribute before processing the cookie.\n \t\t//\n \t\t// Most browsers don't do that for IP addresses, only curl\n-\t\t// version 7.54) and and IE (version 11) do not reject a\n+\t\t// version 7.54) and IE (version 11) do not reject a\n \t\t//     Set-Cookie: a=1; domain=.127.0.0.1\n \t\t// This leading dot is optional and serves only as hint for\n \t\t// humans to indicate that a cookie with \"domain=.bbc.co.uk\"\n```\n\n## Install\n\n```bash\ngo install github.com/Abirdcfly/dupword/cmd/dupword@latest\n```\n\n**Or** install the main branch (including the last commit) with:\n\n```bash\ngo install github.com/Abirdcfly/dupword/cmd/dupword@main\n```\n\n## Usage\n\n### 1. default\n\nRun with default settings(include test file):\n\n**But note that not all repeated words are wrong** see [dupword#4](https://github.com/Abirdcfly/dupword/issues/4) for real code example.\n\n```bash\n$ dupword ./...\n/Users/xxx/go/src/dupword/dupword_test.go:88:10: Duplicate words (the) found\nexit status 3\n```\n\n### 2. skip test file\n\nSkip detection test file(`*_test.go`):\n\n```bash\n$ dupword -test=false ./...\n```\n\n### 3. auto-fix\n\n```bash\n$ dupword -fix ./...\n```\n\n### 4. all options\n\nAll options:\n\n```bash\n$ dupword --help\ndupword: checks for duplicate words in the source code (usually miswritten)\n\nUsage: dupword [-flag] [package]\n\nThis analyzer checks miswritten duplicate words in comments or package doc or string declaration\n\nFlags:\n  -V    print version and exit\n  -all\n        no effect (deprecated)\n  -c int\n        display offending line with this many lines of context (default -1)\n  -cpuprofile string\n        write CPU profile to this file\n  -debug string\n        debug flags, any subset of \"fpstv\"\n  -fix\n        apply all suggested fixes\n  -flags\n        print analyzer flags in JSON\n  -ignore value\n        ignore words\n  -json\n        emit JSON output\n  -keyword value\n        keywords for detecting duplicate words\n  -memprofile string\n        write memory profile to this file\n  -source\n        no effect (deprecated)\n  -tags string\n        no effect (deprecated)\n  -test\n        indicates whether test files should be analyzed, too (default true)\n  -trace string\n        write trace log to this file\n  -v    no effect (deprecated)\n```\n\n### 5. my advice\n\nuse `--keyword=the,and,a` and `-fix` together. I think that specifying only commonly repeated prepositions can effectively avoid false positives. \n\nsee [dupword#4](https://github.com/Abirdcfly/dupword/issues/4) for real code example.\n\n```bash\n$ dupword --keyword=the,and,a -fix ./...\n```\n\n## TODO\n\n- [x] add this linter to golangci-lint\n- [ ] rewrite the detection logic to make it more efficient\n\n## Limitation\n\n1. Only for `*.go` file.But some miswritten occurs in `*.md` or `*.json` file.(example: kubernetes), In this case, my advice is to use [rg](https://github.com/BurntSushi/ripgrep) to do the lookup and replace manually.\n2. When use `-fix`, also running `go fmt` in the dark.([This logic is determined upstream](https://github.com/golang/tools/blob/248c34b88a4148128f89e41923498bd86f805b7d/go/analysis/internal/checker/checker.go#L424-L433), the project does not have this part of the code.)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabirdcfly%2Fdupword","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabirdcfly%2Fdupword","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabirdcfly%2Fdupword/lists"}