{"id":15405080,"url":"https://github.com/razum2um/dead_code_terminator","last_synced_at":"2025-09-10T14:35:50.401Z","repository":{"id":50239006,"uuid":"372383980","full_name":"razum2um/dead_code_terminator","owner":"razum2um","description":"❌ Remove dead conditional branches","archived":false,"fork":false,"pushed_at":"2021-05-31T22:53:56.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T23:51:24.538Z","etag":null,"topics":["dead-code-elimination","dead-code-removal","ruby-parser"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/razum2um.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-31T04:42:36.000Z","updated_at":"2025-03-31T10:42:06.000Z","dependencies_parsed_at":"2022-09-06T10:41:38.940Z","dependency_job_id":null,"html_url":"https://github.com/razum2um/dead_code_terminator","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razum2um%2Fdead_code_terminator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razum2um%2Fdead_code_terminator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razum2um%2Fdead_code_terminator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razum2um%2Fdead_code_terminator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/razum2um","download_url":"https://codeload.github.com/razum2um/dead_code_terminator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249282518,"owners_count":21243551,"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":["dead-code-elimination","dead-code-removal","ruby-parser"],"created_at":"2024-10-01T16:14:57.726Z","updated_at":"2025-04-16T22:25:47.381Z","avatar_url":"https://github.com/razum2um.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeadCodeTerminator\n\n![ci](https://github.com/razum2um/dead_code_terminator/actions/workflows/main.yml/badge.svg)\n[![gem](https://badge.fury.io/rb/dead_code_terminator.svg)](https://rubygems.org/gems/dead_code_terminator)\n[![codecov](https://codecov.io/gh/razum2um/dead_code_terminator/branch/master/graph/badge.svg)](https://app.codecov.io/gh/razum2um/dead_code_terminator)\n\nThis acts like [webpack's DefinePlugin](https://webpack.js.org/plugins/define-plugin/) with minification pass. It allows to eliminate dead code statically, which can be required by regulations.\n\n```ruby\nvalue = if ENV['FLAG']\n  :then_branch\nelse\n  value2 = unless ENV['PRODUCTION']\n    :then_branch\n  else\n    ENV['RUNTIME'] ? :else1 : :else2\n  end\nend\n```\n\n```ruby\n# returns a valid ruby code string back with statically evaluated conditions\nDeadCodeTerminator.strip(string, env: { \"PRODUCTION\" =\u003e true, \"FLAG\" =\u003e false })\n```\n\n```ruby\nvalue = \n\n\n  value2 = \n\n\n    ENV['RUNTIME'] ? :else1 : :else2\n\n \n```\n\nNote: it keeps *precise* code locations (including whitespaces and line-breaks).\nSo if you have hotfix patches from upstream - they'll be applied without conflicts.\nBacktrace line numbers are also preserved and can point to original code.\n\nOther examples can be found in [specs](https://github.com/razum2um/dead_code_terminator/blob/master/spec/dead_code_terminator_spec.rb)\n\n## TODO\n\n- builtin file tree processing\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frazum2um%2Fdead_code_terminator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frazum2um%2Fdead_code_terminator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frazum2um%2Fdead_code_terminator/lists"}