{"id":45316259,"url":"https://github.com/ericodx/swift-cpd","last_synced_at":"2026-04-28T14:01:19.018Z","repository":{"id":344514007,"uuid":"1180829195","full_name":"ericodx/swift-cpd","owner":"ericodx","description":"Detect and eliminate duplicated logic in Swift and Objective-C/C codebases to improve maintainability and code quality.","archived":false,"fork":false,"pushed_at":"2026-03-30T13:21:47.000Z","size":1062,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-02T02:46:20.616Z","etag":null,"topics":["cli","copy-paste-detector","swift","swift-package-manager","xcode-plugin"],"latest_commit_sha":null,"homepage":"https://github.com/ericodx/swift-cpd","language":"Swift","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/ericodx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":"Docs/GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-13T13:07:07.000Z","updated_at":"2026-03-30T13:27:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ericodx/swift-cpd","commit_stats":null,"previous_names":["ericodx/swift-cpd"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ericodx/swift-cpd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericodx%2Fswift-cpd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericodx%2Fswift-cpd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericodx%2Fswift-cpd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericodx%2Fswift-cpd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericodx","download_url":"https://codeload.github.com/ericodx/swift-cpd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericodx%2Fswift-cpd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31485516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"ssl_error","status_checked_at":"2026-04-06T17:22:54.741Z","response_time":112,"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":["cli","copy-paste-detector","swift","swift-package-manager","xcode-plugin"],"created_at":"2026-02-21T07:51:36.744Z","updated_at":"2026-04-28T14:01:19.007Z","avatar_url":"https://github.com/ericodx.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift Code Duplication Detector\n\n[![Swift Package Index](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fericodx%2Fswift-cpd%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/ericodx/swift-cpd)\n[![Swift Package Index](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fericodx%2Fswift-cpd%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/ericodx/swift-cpd)\n[![CI](https://img.shields.io/github/actions/workflow/status/ericodx/swift-cpd/main-analysis.yml?branch=main\u0026style=flat-square\u0026logo=github\u0026logoColor=white\u0026label=CI\u0026color=4CAF50)](https://github.com/ericodx/swift-cpd/actions)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ericodx-swift-cpd\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ericodx-swift-cpd)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ericodx-swift-cpd\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=ericodx-swift-cpd)\n![mutation score](https://img.shields.io/badge/mutation%20score-91.4%25-lightgray?logo=jest\u0026logoColor=white)\n\n**Detect and eliminate duplicated logic in Swift and Objective-C/C codebases to improve maintainability and code quality.**\n\n`swift-cpd` performs structural analysis to detect duplication patterns across Swift, Objective-C, and C codebases, going beyond simple text-based detection.\n\n---\n\n## Why\n\nCode duplication leads to:\n- inconsistent behavior across features\n- fragile refactors and hidden regressions\n- increased maintenance cost and cognitive load\n\n`swift-cpd` helps you detect and address duplication early, supporting long-term code health and developer productivity.\n\n---\n\n## Features\n\n- Structural duplication detection (AST-based)\n- Works with Swift, Objective-C, and C codebases\n- Enforces duplication rules in CI pipelines\n- Supports code quality and governance practices\n\n---\n\n## Install\n\n```bash\nbrew tap ericodx/homebrew-tools\nbrew install swift-cpd\n```\n\nOther installation methods — pre-built binary, build from source, pre-commit hook, Xcode plugin — are covered in the [Installation Guide](Docs/INSTALLATION.md).\n\n## Quick start\n\n```bash\n# Generate a config file (auto-detects your source directories)\nswift-cpd init\n\n# Run\nswift-cpd\n```\n\nExample output:\n\n```\nClone detected — Type 2 | 15 lines | 120 tokens | 100.0% similarity\n  Sources/App/Services/UserService.swift    :  34 –  48\n  Sources/App/Services/ProductService.swift :  71 –  85\n\n1 clone(s) found in 32 file(s) — 2.1% duplication — 0.8s\n```\n\n## Configuration\n\nDrop a `.swift-cpd.yml` in the project root to control paths, thresholds, excluded files, and output format:\n\n```yaml\npaths:\n  - Sources/\nminimumTokenCount: 50\nminimumLineCount: 5\nenabledCloneTypes: [1, 2, 3, 4]\nignoreSameFile: true\nexclude:\n  - \"**/*Tests*\"\n  - \"**/*.generated.swift\"\n```\n\nFull reference in the [Usage \u0026 Configuration Guide](Docs/USAGE.md).\n\n## Documentation\n\n| Document | Description |\n|---|---|\n| [Installation](Docs/INSTALLATION.md) | Homebrew, binary, source, pre-commit, Xcode plugin |\n| [Usage \u0026 Configuration](Docs/USAGE.md) | CLI options, YAML config, output formats, CI integration |\n| [Xcode Plugin](Docs/xcode-plugin.md) | Step-by-step Xcode and SPM plugin setup |\n| [Architecture](Docs/Architecture/README.md) | System design, pipeline, detection algorithms |\n| [CodeBase Reference](Docs/CodeBase/README.md) | Every type, protocol, and algorithm documented |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericodx%2Fswift-cpd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericodx%2Fswift-cpd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericodx%2Fswift-cpd/lists"}