{"id":13771828,"url":"https://github.com/tommy-muehle/go-mnd","last_synced_at":"2025-05-15T17:06:49.480Z","repository":{"id":43088472,"uuid":"172142194","full_name":"tommy-muehle/go-mnd","owner":"tommy-muehle","description":"Magic number detector for Go.","archived":false,"fork":false,"pushed_at":"2023-12-21T08:59:47.000Z","size":1521,"stargazers_count":197,"open_issues_count":12,"forks_count":21,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-02T15:41:58.643Z","etag":null,"topics":["analysis","cli","code-checker","detector","go","go-vet","golang","magic-numbers","static-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/tommy-muehle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-22T22:18:36.000Z","updated_at":"2025-04-25T08:40:24.000Z","dependencies_parsed_at":"2023-01-04T14:11:25.303Z","dependency_job_id":"915a0fe4-c4c6-4987-a202-d75c993538f7","html_url":"https://github.com/tommy-muehle/go-mnd","commit_stats":{"total_commits":57,"total_committers":7,"mean_commits":8.142857142857142,"dds":0.4385964912280702,"last_synced_commit":"86c7103981d88b6598d38e3927275cab84f17192"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommy-muehle%2Fgo-mnd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommy-muehle%2Fgo-mnd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommy-muehle%2Fgo-mnd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommy-muehle%2Fgo-mnd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tommy-muehle","download_url":"https://codeload.github.com/tommy-muehle/go-mnd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"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":["analysis","cli","code-checker","detector","go","go-vet","golang","magic-numbers","static-analysis"],"created_at":"2024-08-03T17:00:56.035Z","updated_at":"2025-05-15T17:06:44.472Z","avatar_url":"https://github.com/tommy-muehle.png","language":"Go","funding_links":[],"categories":["Linters"],"sub_categories":["Misc"],"readme":"# go-mnd - Magic number detector for Golang\n\n\u003cimg align=\"right\" width=\"250px\" src=\"https://github.com/tommy-muehle/go-mnd/blob/master/images/logo.png\"\u003e\n\nA vet analyzer to detect magic numbers.\n\n\u003e **What is a magic number?**  \n\u003e A magic number is a numeric literal that is not defined as a constant, but which may change, and therefore can be hard to update. It's considered a bad programming practice to use numbers directly in any source code without an explanation. It makes programs harder to read, understand, and maintain.\n\n## Project status\n\n![CI](https://github.com/tommy-muehle/go-mnd/workflows/CI/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/tommy-muehle/go-mnd)](https://goreportcard.com/report/github.com/tommy-muehle/go-mnd)\n[![codecov](https://codecov.io/gh/tommy-muehle/go-mnd/branch/master/graph/badge.svg)](https://codecov.io/gh/tommy-muehle/go-mnd)\n\n## Install\n\n### Local\n\nThis analyzer requires Golang in version \u003e= 1.12 because it's depends on the **go/analysis** API.\n\n```\ngo get -u github.com/tommy-muehle/go-mnd/v2/cmd/mnd\n```\n\n### Github action\n\nYou can run go-mnd as a GitHub action as follows:\n\n```\nname: Example workflow\non:\n  push:\n    branches:\n      - master\n  pull_request:\n    branches:\n      - master\njobs:\n  tests:\n    runs-on: ubuntu-latest\n    env:\n      GO111MODULE: on\n    steps:\n      - name: Checkout Source\n        uses: actions/checkout@v2\n      - name: Run go-mnd\n        uses: tommy-muehle/go-mnd@master\n        with:\n          args: ./...\n```\n\n### GitLab CI\n\nYou can run go-mnd inside a GitLab CI pipeline as follows:\n\n```\nstages:\n  - lint\n\ngo:lint:mnd:\n  stage: lint\n  needs: []\n  image: golang:latest\n  before_script:\n    - go get -u github.com/tommy-muehle/go-mnd/v2/cmd/mnd\n    - go mod tidy\n    - go mod vendor\n  script:\n    - go vet -vettool $(which mnd) ./...\n```\n\n### Homebrew\n\nTo install with [Homebrew](https://brew.sh/), run:\n\n```\nbrew tap tommy-muehle/tap \u0026\u0026 brew install tommy-muehle/tap/mnd\n```\n\n### Docker\n\nTo get the latest available Docker image:\n\n```\ndocker pull tommymuehle/go-mnd\n```\n\n### Windows\n\nOn Windows download the [latest release](https://github.com/tommy-muehle/go-mnd/releases).\n\n## Usage\n\n[![asciicast](https://asciinema.org/a/231021.svg)](https://asciinema.org/a/231021)\n\n```\ngo vet -vettool $(which mnd) ./...\n```\n\nor directly\n\n```\nmnd ./...\n```\n\nor via Docker\n\n```\ndocker run --rm -v \"$PWD\":/app -w /app tommymuehle/go-mnd:latest ./...\n```\n\n## Options\n\nThe ```-checks``` option let's you define a comma separated list of checks.\n\nThe ```-ignored-numbers``` option let's you define a comma separated list of numbers to ignore.  \nFor example: `-ignored-numbers=1000,10_000,3.14159264`\n\nThe ```-ignored-functions``` option let's you define a comma separated list of function name regexp patterns to exclude.  \nFor example: `-ignored-functions=math.*,http.StatusText,make`\n\nThe ```-ignored-files``` option let's you define a comma separated list of filename regexp patterns to exclude.  \nFor example: `-ignored-files=magic_.*.go,.*_numbers.go`\n\n## Checks\n\nBy default this detector analyses arguments, assigns, cases, conditions, operations and return statements.\n\n* argument\n\n```\nt := http.StatusText(200)\n```\n\n* assign\n\n```\nc := \u0026http.Client{\n    Timeout: 5 * time.Second,\n}\n```\n\n* case\n\n```\nswitch x {\n    case 3:\n}\n```\n\n* condition\n\n```\nif x \u003e 7 {\n}\n```\n\n* operation\n\n```\nvar x, y int\ny = 10 * x\n```\n\n* return\n\n```\nreturn 3\n```\n\n## Excludes\n\nBy default the numbers 0 and 1 as well as test files are excluded! \n\n### Further known excludes\n\nThe function \"Date\" in the \"Time\" package.\n\n```\nt := time.Date(2017, time.September, 26, 12, 13, 14, 0, time.UTC)\n```\n\nAdditional custom excludes can be defined via option flag.\n\n## Development\n\n### Build\n\nYou can build the binary with:\n\n```\nmake\n```\n\n### Tests\n\nYou can run all unit tests using:\n\n```\nmake test\n```\n\nAnd with coverage report:\n\n```\nmake test-coverage\n```\n\n### Docker image\n\nYou can also build locally the docker image by using the command:\n\n```\nmake image\n```\n\n## Stickers\n\n\u003cp style=\"float: left;\"\u003e\n    \u003cimg alt=\"Stickers image\" width=\"200px\" src=\"https://github.com/tommy-muehle/go-mnd/blob/master/images/stickers.jpg\" /\u003e\n    \u003cimg alt=\"Sticker image\" width=\"200px\" src=\"https://github.com/tommy-muehle/go-mnd/blob/master/images/sticker.jpg\" /\u003e\n\u003c/p\u003e\n\nJust drop me a message via Twitter DM or email if you want some go-mnd stickers\nfor you or your Gopher usergroup.\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftommy-muehle%2Fgo-mnd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftommy-muehle%2Fgo-mnd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftommy-muehle%2Fgo-mnd/lists"}