{"id":18494937,"url":"https://github.com/qaware/refactobot","last_synced_at":"2026-05-01T19:32:19.660Z","repository":{"id":77410232,"uuid":"98463096","full_name":"qaware/refactobot","owner":"qaware","description":"Automate Code Reorganizations","archived":false,"fork":false,"pushed_at":"2018-08-17T13:28:27.000Z","size":391,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-14T03:15:05.753Z","etag":null,"topics":["hacktoberfest","java","refactoring-tools"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/qaware.png","metadata":{"files":{"readme":"README.adoc","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}},"created_at":"2017-07-26T20:26:39.000Z","updated_at":"2022-10-23T20:00:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"4bbc2289-4e72-46f2-80c5-d6ae375e8dd4","html_url":"https://github.com/qaware/refactobot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/qaware/refactobot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Frefactobot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Frefactobot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Frefactobot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Frefactobot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qaware","download_url":"https://codeload.github.com/qaware/refactobot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Frefactobot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32510686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["hacktoberfest","java","refactoring-tools"],"created_at":"2024-11-06T13:22:46.795Z","updated_at":"2026-05-01T19:32:19.626Z","avatar_url":"https://github.com/qaware.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Refactobot - Automate code reorganizations in large Java codebases.\n\nimage:https://travis-ci.org/qaware/refactobot.svg?branch=master[\"Build Status\", link=\"https://travis-ci.org/qaware/refactobot\"]\nimage:https://coveralls.io/repos/github/qaware/refactobot/badge.svg?branch=master[\"Coverage Status\", link=\"https://coveralls.io/github/qaware/refactobot?branch=master\"]\nimage:http://img.shields.io/badge/license-MIT-green.svg?style=flat[\"License\"]\n\nMoving or renaming individual classes is a no-brainer in today's IDEs. But what if you want to rename thousands of\nclasses in hundreds of packages? What if you want to reorganize a large codebase into a new module structure?\n\nRefactobot takes a codebase and some transformations, and applies them to the codebase fully automatically,\nadapting all references. Transformations may include changing class and package names\nand moving classes between packages and modules (in a multi-module build). Transformations\nare programmed in a very simple Kotlin DSL.\n\n\n== Features\n\nAutomated and fast::\n  Transforming a codebase just means running a script, and processes thousands of classes within seconds. This means\n  you can reliably reproduce the transformation as many times as needed, as the codebase is still undergoing changes.\n\nFully preserves formatting, whitespace, and comments::\n  Refactobot only touches references to classes, when they are renamed or moved. All other code and formatting remains\n  exactly as it is.\n\nDeclarative and powerful transformation language::\n  Transformations are expressed declaratively in a Kotlin-based DSL. Be it simple move commands, regex-based matching,\n  or custom scripting (in Kotlin) -- refactoring scripts usually are just a few lines of simple code.\n\nStructure101 class map import::\n  If you use Structure 101 for planning your refactoring, you can directly export a class map and apply it using Refactobot.\n  If you have a class map from some other source, it should be simple to load.\n\nBattle-tested::\n  Refactobot was used successfully to establish a completely revamped module structure for a 200kloc codebase, which\n  involved moving almost every class to a new place, and introduce uniform naming and packaging conventions.\n\nHackable::\n  Since every codebase is different, some adaptation may be needed in some cases. Refactobot is easily extensible\n  due to its modular design. On the other hand, do not expect a polished product-like experience. This is for developers!\n\n\n== Usage Examples\n\nRefactobot has no command line interface and is simply invoked from Kotlin code via its simple API.\nYou can find a working test case in `FullIntegrationTest`, which you can use as a start and adapt to your use case.\nBelow are some examples that illustrate the DSL.\n\n=== 1) Rename some classes, based on regular expressions\n\nIf you want to change some class naming schemes, you can use regular expressions\non the class name:\n\n[source,kotlin]\n----\nval refactobot = Refactobot.configure { // Create and configure the refactobot instance.\n\n    refactor { // In this block, we specify the transformations to apply to the codebase.\n        renameFile(\"\"\"(.*)DaoBean\\.java\"\"\" to \"$1DaoImpl.java\")\n    }\n}\n\nrefactobot.run(\"/path/to/codebase\") // The actual invocation of the tool.\n----\n\n=== 2) Fix the base package name\n\nThis example shows how you can express your transformation in simple Kotlin code, which operates on the\nfile name and path:\n\n[source,kotlin]\n----\nval oldBasePackage = \"org/example/legacybasepackage/\"\nval newBasePackage = \"org/example/newbasepackage/\"\n\nval refactobot = Refactobot.configure {\n\n    refactor {\n\n        if (this.path.startsWith(oldBasePackage)) {\n            this.path = newBasePackage + this.path.removePrefix(oldBasePackage)\n        }\n    }\n}\n\nrefactobot.run(\"/path/to/codebase\")\n----\n\n=== 3) Apply a mapping between class names\n\nIf you have a map with fully qualified class names, you can use it like this:\n\n[source,kotlin]\n----\nval refactobot = Refactobot.configure {\n\n    refactor {\n        applyClassMap(mapOf(\n            \"org.example.codebase.SomeClass\" to \"org.example.codebase.NewClassName\",\n            \"org.example.codebase.SomeOtherClass\" to \"org.example.codebase.ShinyNewOtherClassName\"\n        ))\n    }\n}\n\nrefactobot.run(\"/path/to/codebase\")\n----\n\nAlternatively, if you developed that map with Structure 101, you can import the XML file exported from there:\n\n[source,kotlin]\n----\nval refactobot = Refactobot.configure {\n\n    refactor {\n        applyClassMap(Structure101ClassmapReader.readClassmapXml(\"classmap.xml\"))\n    }\n}\n\nrefactobot.run(\"/path/to/codebase\")\n----\n\n\n== Assumptions and Limitations\n\nA tool cannot do everything by magic, so there are a few limitations that you should be aware of:\n\nBuild-tool-agnostic::\n  Refactobot understands Java, but it does not know (or care about) your build tool, except when discovering module\n  names and directories in a codebase. It was used on a multimodule Maven project, but can equally handle Gradle\n  and other build tools. Of course this means that you must manually handle any necessary changes to your build files,\n  e.g., when module dependencies change.\n\nSome sane Java conventions::\n  Some conventions are industry standard in the Java community, although they are not enforced by the Java compiler.\n  Refactobot relies on these conventions nevertheless. If your codebase violates them, you may think about fixing this\n  first. When detecting such a case, Refactobot tries to give helpful error messages. In particular, we require that:\n  * The directory structure reflects the package structure, i.e., files under `foo/bar` belong to package `foo.bar`.\n  * Each file contains exactly one top-level type (class, interface, enum, ...).\n  * Type names start with capital letters. Package names start with small letters.\n\nNo *-imports::\n  Currently, *-imports are not supported. I found it easy to work around this, since many IDEs now support expanding\n  *-imports automatically.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaware%2Frefactobot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqaware%2Frefactobot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaware%2Frefactobot/lists"}