{"id":31727127,"url":"https://github.com/arya458/dead-code-detector-gradle-plugin","last_synced_at":"2025-10-09T06:18:31.521Z","repository":{"id":314330183,"uuid":"1053413889","full_name":"arya458/Dead-Code-Detector-Gradle-Plugin","owner":"arya458","description":"Dead Code Detector is a Gradle plugin that helps you find unused classes, functions, resources, and dependencies in your Kotlin/Java projects.","archived":false,"fork":false,"pushed_at":"2025-09-28T11:25:27.000Z","size":291,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-28T11:41:28.472Z","etag":null,"topics":["code-cleanup","dead-code","dependencies-checking","gradle","gradle-plugin","java","kotlin","resources-checker","static-analysis","unused-code"],"latest_commit_sha":null,"homepage":"https://arya458.github.io/Dead-Code-Detector-Gradle-Plugin/","language":"Kotlin","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/arya458.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-09T12:18:51.000Z","updated_at":"2025-09-28T11:25:30.000Z","dependencies_parsed_at":"2025-09-11T22:28:27.690Z","dependency_job_id":null,"html_url":"https://github.com/arya458/Dead-Code-Detector-Gradle-Plugin","commit_stats":null,"previous_names":["arya458/dead-code-detector-gradle-plugin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arya458/Dead-Code-Detector-Gradle-Plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arya458%2FDead-Code-Detector-Gradle-Plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arya458%2FDead-Code-Detector-Gradle-Plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arya458%2FDead-Code-Detector-Gradle-Plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arya458%2FDead-Code-Detector-Gradle-Plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arya458","download_url":"https://codeload.github.com/arya458/Dead-Code-Detector-Gradle-Plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arya458%2FDead-Code-Detector-Gradle-Plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000853,"owners_count":26082950,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["code-cleanup","dead-code","dependencies-checking","gradle","gradle-plugin","java","kotlin","resources-checker","static-analysis","unused-code"],"created_at":"2025-10-09T06:18:29.241Z","updated_at":"2025-10-09T06:18:31.513Z","avatar_url":"https://github.com/arya458.png","language":"Kotlin","readme":"# ⚠️ For Android Version [Click Here](https://github.com/arya458/Dead-Code-Detector-Gradle-Plugin/tree/main/PluginAndroid)\n# Dead Code Detector Gradle Plugin\n\n**Dead Code Detector** is a Kotlin-based Gradle plugin that analyzes compiled classes, resources, and dependencies, generating a human-readable report of unused (dead) code, resources, and libraries in your project.\n\n---\n\n## Table of contents\n\n* [Why use this plugin?](#why-use-this-plugin)\n* [Features](#features)\n* [Quickstart (install \u0026 run)](#quickstart-install--run)\n* [Configuration](#configuration)\n* [Tasks](#tasks)\n* [Report format \u0026 example](#report-format--example)\n* [CI integration](#ci-integration)\n* [How it works (brief)](#how-it-works-brief)\n* [Limitations \u0026 notes](#limitations--notes)\n* [Contributing](#contributing)\n* [License](#license)\n\n---\n\n## Why use this plugin?\n\nKeeping a codebase tidy improves maintainability, build times, and developer confidence. This plugin helps you find:\n\n* Unreferenced top-level functions and fields\n* Unused classes\n* Dead resources\n* Unused dependencies\n\nIt produces a plain-text report you can read locally or archive in CI.\n\n## Features\n\n* Detects unused classes, top-level functions, and top-level fields in Kotlin/Java projects\n* Detects unused dependencies in your Gradle build\n* Detects unused resources (optionally scanning `src/main/resources` and `src/test/resources`)\n* Grouped, human-readable reports (method signatures, field types, dependency notations)\n* Configurable to keep public API, include/exclude tests, scan/exclude resources, exclude packages\n* Support for ignoring elements annotated with specific annotations\n* Optionally fail the build when dead code is detected\n* Can run manually or be attached to `check` for CI\n\n## Quickstart (install \u0026 run)\n\nApply the plugin in your module's `build.gradle.kts`:\n\n```kotlin\nplugins {\n  id(\"io.github.arya458.dead-code-detector\") version \"0.0.5\"\n}\n```\n\nThen run the detector manually:\n\n```bash\n./gradlew deadCodeDetector\n```\n\nOr include it in your verification pipeline:\n\n```bash\n./gradlew check\n```\n\nBy default the plugin writes its output to:\n\n```\nbuild/reports/dead-code-detector/report.txt\n```\n\n(You can override this in the configuration: see below.)\n\n## Configuration\n\nConfigure the plugin with the `deadCodeDetector` extension in your module's `build.gradle.kts`:\n\n```kotlin\ndeadCodeDetector {\n    // Fail the build if any dead code is detected\n    failOnDeadCode = true\n\n    // Scan test classes + test resources when true\n    includeTests = false\n\n    // If true, public API (public functions/fields) are ignored from detection\n    keepPublicApi = false\n\n    // (Planned) Automatically clear all dead code — not yet implemented\n    // clearAllDeadCode = true\n\n    // Resource scanning\n    includeResources = false\n    resourceDir = \"src/main/resources\"\n    testResourceDir = \"src/test/res\"\n\n    // Add package prefixes (or regex-like entries) to exclude from scanning\n    excludePackages.add(\"com.mycompany.generated\")\n\n    // Ignore elements annotated with these annotations\n    keepAnnotations.add(\"javax.inject.Inject\")\n}\n```\n\n### Notes about configuration\n\n* If you want to detect unused public API, set `keepPublicApi = false`. Be careful: this may flag intentionally public functions used by other modules or reflective consumers.\n* If you enable `includeResources`, the plugin will scan your resource directories (`resourceDir`, `testResourceDir`) for unused entries.\n* If you want to detect unused dependencies, simply run the plugin — unused dependency detection is included in the report.\n* If the plugin cannot find compiled classes, run `./gradlew classes` (or your module's compile tasks) before running the detector.\n\n## Tasks\n\n* `deadCodeDetector` — main task that scans compiled classes, resources, and dependencies, producing the report\n* Integration with `check` — if wired in the plugin, `./gradlew check` will run the detector (depending on configuration)\n\n## Report format \u0026 example\n\nThe report is a plain text file grouped by dead classes, methods, fields, resources, and dependencies. A typical (shortened) example looks like this:\n\n```\n# Dead Code Detector Report\n\nSummary:\n  * Dead methods: 2\n  * Dead fields: 1\n  * Dead classes: 1\n  * Dead resources: 1\n  * Unused dependencies: 1\n\nDead Classes:\n  * com.example.unused.MyUnusedClass\n\nDead Methods:\nClass: com.example.MainKt • deadCode(String) : void\n\nDead Fields:\nClass: com.example.MainKt • unusedValue : String\n\nDead Resources:\n  * src/main/resources/old_config.json\n\nUnused Dependencies:\n  * implementation(\"com.squareup.retrofit2:retrofit:2.9.0\")\n```\n\nThe plugin attempts to present readable signatures, resource paths, and dependency notations.\n\n## CI integration\n\nExample GitHub Actions workflow:\n\n```yaml\nname: CI\non: [push, pull_request]\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: Set up JDK\n        uses: actions/setup-java@v4\n        with:\n          java-version: '17'\n      - name: Run Gradle build + dead-code-detector\n        run: ./gradlew check --no-daemon\n```\n\nIf you prefer the detector not to fail CI, set `failOnDeadCode = false` in the extension.\n\n## How it works (brief)\n\nThe plugin analyzes compiled class files, resources, and dependency references to determine which items are never referenced. Bytecode-level analysis makes detection reliable for compiled artifacts, but reflection or generated code may cause false positives.\n\nIf you plan to use this in multi-module projects, run the detector in modules where compiled classes are available; otherwise, point to the compiled class directories if supported by the plugin configuration.\n\n## Limitations \u0026 notes\n\n* **Local variables** are not detected (Kotlin compiler may remove them in bytecode).\n* **Reflection, dynamic calls, annotation processors, and dependency injection** can create false positives — code/resources/dependencies used only reflectively might appear unused.\n* **Public API**: if your project exposes public functions/classes used by external consumers, set `keepPublicApi = true` to avoid false positives.\n* Run the plugin after building the classes (`./gradlew classes`) so compiled output is present.\n* `clearAllDeadCode` is currently a planned feature and not implemented.\n\n## Contributing\n\nContributions and issues are welcome.\n\nIdeas for improvements:\n\n* Implement `clearAllDeadCode` option\n* Add HTML output or colored console output\n* Add more fine-grained ignore rules (annotations, regex, resource types)\n* Add integration with Detekt or other static analysis tools\n\nPlease open issues or PRs against this repository.\n\n## License\n\nMIT License — feel free to use and modify the code.\n\n---\n\n*Generated by a friendly README polish to make the repository easier for others to use.*","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farya458%2Fdead-code-detector-gradle-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farya458%2Fdead-code-detector-gradle-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farya458%2Fdead-code-detector-gradle-plugin/lists"}