{"id":28708306,"url":"https://github.com/pmd/pmd-scm","last_synced_at":"2025-07-26T15:11:40.020Z","repository":{"id":79611237,"uuid":"229721598","full_name":"pmd/pmd-scm","owner":"pmd","description":"Source Code Minimizer","archived":false,"fork":false,"pushed_at":"2025-01-31T17:35:06.000Z","size":166,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-07-09T11:29:11.071Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-12-23T09:38:57.000Z","updated_at":"2025-03-01T10:56:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"650dc3a2-d3a7-4bc4-a667-ba5e81658dde","html_url":"https://github.com/pmd/pmd-scm","commit_stats":{"total_commits":30,"total_committers":3,"mean_commits":10.0,"dds":0.5,"last_synced_commit":"7a9eb5c378d92f4116d54151debb8e9fb72e9418"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pmd/pmd-scm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmd%2Fpmd-scm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmd%2Fpmd-scm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmd%2Fpmd-scm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmd%2Fpmd-scm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmd","download_url":"https://codeload.github.com/pmd/pmd-scm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmd%2Fpmd-scm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265216098,"owners_count":23729266,"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":[],"created_at":"2025-06-14T18:10:32.062Z","updated_at":"2025-07-26T15:11:40.003Z","avatar_url":"https://github.com/pmd.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Source code minimizer (pmd-scm)\n\n[![Build Status](https://github.com/pmd/pmd-scm/workflows/build/badge.svg?branch=main)](https://github.com/pmd/pmd-scm/actions?query=workflow%3Abuild)\n\nThis is a tool based on [PMD](https://pmd.github.io). It is intended to minimize one or several source code files, while retaining some invariant (such as a specific compiler error message).\n\nSee\n* [#2103 [core] Feature request: compiler-crashing test case minimization](https://github.com/pmd/pmd/issues/2103)\n* [#2142 [core] Initial implementation of Source Code Minimizer](https://github.com/pmd/pmd/pull/2142)\n\nfor thoughts and discussions.\n\n## Building\n\nJust run\n\n    ./mvnw clean verify\n\nThis will generate a binary distribution zip which contains all dependencies. The file is\nin `pmd-scm-dist/target/pmd-scm-bin-1.0.0-SNAPSHOT.zip`. Just unzip it.\n\n## Running\n\nDrop all annotations from the source file:\n\n    path/to/bin/run.sh scm --language java \\\n        --input-file pmd-scm/src/main/java/net/sourceforge/pmd/scm/SCMConfiguration.java \\\n        --output-file test.java \\\n        --strategy xpath --xpath-expression \"//Annotation\"\n\nLet's look at more real-life example. Suppose, we have two files:\n\n**TestResource-orig.java:**\n```java\nclass TestResource {\n    int func() {\n        System.err.println(\"Hello World!\");\n        return 123;\n    }\n\n    void unused() {\n        // unused\n    }\n}\n```\n\n**Main-orig.java:**\n```java\nclass Main {\n    public static void main(String[] args) {\n        String str = new TestResource().func();\n\n        return 123;\n    }\n}\n```\n\nIf we try compiling it, we get:\n\n    $ javac TestResource.java Main.java \n    Main.java:3: error: incompatible types: int cannot be converted to String\n            String str = new TestResource().func();\n                                                ^\n    Main.java:5: error: incompatible types: unexpected return value\n            return 123;\n                   ^\n    2 errors\n\nSuppose, we want to minimize these two Java source files simultaneously, while retaining the invariant: the compiler should print\n\n    error: incompatible types: int cannot be converted to String\n\nThen, we could run\n\n    $ path/to/bin/run.sh scm --language java \\\n          --input-file TestResource-orig.java Main-orig.java \\\n          --output-file TestResource.java Main.java \\\n          --invariant message --printed-message \"error: incompatible types: int cannot be converted to String\" \\\n          --command-line \"javac TestResource.java Main.java\" \\\n          --strategy greedy\n    Original file(s): 290 bytes, 77 nodes.\n    After initial white-space cleanup: size 258 bytes (88%), 77 nodes (100%)\n    After pass #1: size 255 bytes (87%), 64 nodes (83%)\n    After pass #2: size 244 bytes (84%), 57 nodes (74%)\n    After pass #3: size 205 bytes (70%), 51 nodes (66%)\n    After pass #4: size 192 bytes (66%), 46 nodes (59%)\n    After pass #5: size 181 bytes (62%), 39 nodes (50%)\n    After pass #6: size 179 bytes (61%), 39 nodes (50%)\n    After final white-space cleanup: size 149 bytes (51%), 39 nodes (50%)\n    After blank line clean up: size 147 bytes (50%), 39 nodes (50%)\n\nNow, we get the following files:\n\n**TestResource.java:**\n```java\nclass TestResource {\n    int func() {\n    }\n}\n```\n\n**Main.java:**\n```java\nclass Main {\n    public static void main() {\n        String str = new TestResource().func();\n    }\n}\n```\n\n    $ javac TestResource.java Main.java \n    TestResource.java:3: error: missing return statement\n        }\n        ^\n    Main.java:3: error: incompatible types: int cannot be converted to String\n            String str = new TestResource().func();\n                                                ^\n    2 errors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmd%2Fpmd-scm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmd%2Fpmd-scm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmd%2Fpmd-scm/lists"}