{"id":49922732,"url":"https://github.com/shipmonk-rnd/copy-paste-detector","last_synced_at":"2026-05-16T21:20:11.909Z","repository":{"id":357079394,"uuid":"1136185825","full_name":"shipmonk-rnd/copy-paste-detector","owner":"shipmonk-rnd","description":"🪞 Structural code duplication detector for PHP. Detect copy pasted code in your PHP codebase.","archived":false,"fork":false,"pushed_at":"2026-05-11T09:29:37.000Z","size":169,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-11T09:30:26.917Z","etag":null,"topics":["ast","ci","clone-detection","copy-paste-detector"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/shipmonk-rnd.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-17T08:12:53.000Z","updated_at":"2026-05-11T09:06:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/shipmonk-rnd/copy-paste-detector","commit_stats":null,"previous_names":["shipmonk-rnd/copy-paste-detector"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/shipmonk-rnd/copy-paste-detector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fcopy-paste-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fcopy-paste-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fcopy-paste-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fcopy-paste-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shipmonk-rnd","download_url":"https://codeload.github.com/shipmonk-rnd/copy-paste-detector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fcopy-paste-detector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33119176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"ssl_error","status_checked_at":"2026-05-16T18:38:29.903Z","response_time":115,"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":["ast","ci","clone-detection","copy-paste-detector"],"created_at":"2026-05-16T21:20:11.183Z","updated_at":"2026-05-16T21:20:11.895Z","avatar_url":"https://github.com/shipmonk-rnd.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Copy-Paste Detector\n\nAn AST-based structural code clone detector for PHP, inspired by the CloneDR methodology.\nThis tool efficiently detects Type-2 (parameterized) code clones using AST analysis and hash-based exact matching.\n\n\n## Installation\n\n```bash\ncomposer require --dev shipmonk/copy-paste-detector\n```\n\n\n## Basic Usage\n\n```bash\nvendor/bin/copy-paste-detector src/\n```\n\n\n## CLI Options\n\n- `--config=config.php` or `-c config.php`\n  - Path to configuration file\n  - Defaults to `copy-paste-detector.php` in current directory\n  - Configuration file must return a `CopyPasteDetector\\Config\\Config` instance\n\n\n- `--min-node-count=100` or `-m 100`\n  - Minimum number of AST nodes for a subtree to be considered\n  - Defaults to 50\n\n\n- `--cache-dir=cache/`\n  - Directory for caching parsed structures\n  - Defaults to system temp directory\n\n\n- `--patch=changes.patch`\n  - Path to a git diff/patch file (extension must be `.patch` or `.diff`)\n  - Only reports clone groups with at least one instance fully inside the patch's added lines.\n  - Requires `sebastian/diff` to be installed.\n\n\n- `--ansi` / `--no-ansi`\n  - Force enable or disable ANSI color output\n  - By default, colors are auto-detected based on the terminal\n\n\n## Check if MR copied code from elsewhere\n\n```bash\ngit diff master...HEAD \u003e changes.patch\nvendor/bin/copy-paste-detector --patch=changes.patch src/ tests/\n```\n\n- A clone group is reported if at least one instance lies fully inside the patch's added lines. The other instances may be either elsewhere in the codebase or also inside the patch.\n\n\n## Configuration File\n\nCreate a `copy-paste-detector.php` file in your project root to configure detection settings:\n\n```php\n\u003c?php\n\nuse CopyPasteDetector\\Config\\Config;\n\n$config = new Config();\n\n// Set paths to analyze\n$config-\u003esetPaths(['src/', 'tests/']);\n\n// Set the minimum node count for clone detection\n$config-\u003esetMinNodeCount(50);\n\n// Set cache directory (optional, defaults to system temp directory)\n$config-\u003esetCacheDir('cache/copy-paste-detector/');\n\n// Exclude paths from analysis\n$config-\u003esetExcludePaths(['tests/_fixtures', 'src/Generated/']);\n\n// Enable clickable links to your IDE\n$config-\u003esetEditorUrl('phpstorm://open?file={file}\u0026line={line}');\n\n// Configure anonymization strategies\n$config-\u003esetAnonymizeVariables(true); // treat variable names like `$foo` and `$bar` as equivalent\n$config-\u003esetAnonymizeLiterals(false); // treat string and number literals as equivalent\n$config-\u003esetAnonymizeNames(false); // treat function and class names as equivalent\n$config-\u003esetAnonymizeIdentifiers(false); // treat method and constant names as equivalent\n\nreturn $config;\n```\n\n\n## Contributing\n- Check your code by `composer check`\n- Autofix coding-style by `composer fix:cs`\n- All functionality must be tested\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshipmonk-rnd%2Fcopy-paste-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshipmonk-rnd%2Fcopy-paste-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshipmonk-rnd%2Fcopy-paste-detector/lists"}