{"id":15017791,"url":"https://github.com/jetbrains/ruby-type-inference","last_synced_at":"2025-04-07T15:07:06.774Z","repository":{"id":62553512,"uuid":"85180339","full_name":"JetBrains/ruby-type-inference","owner":"JetBrains","description":"Dynamic definitions and types provider for ruby static analysis","archived":false,"fork":false,"pushed_at":"2020-01-14T18:07:31.000Z","size":1744,"stargazers_count":136,"open_issues_count":17,"forks_count":7,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-31T12:08:39.460Z","etag":null,"topics":["dynamic-analysis","ruby","rubymine","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JetBrains.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}},"created_at":"2017-03-16T09:57:01.000Z","updated_at":"2024-12-05T11:41:10.000Z","dependencies_parsed_at":"2022-11-03T04:30:31.142Z","dependency_job_id":null,"html_url":"https://github.com/JetBrains/ruby-type-inference","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fruby-type-inference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fruby-type-inference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fruby-type-inference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fruby-type-inference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JetBrains","download_url":"https://codeload.github.com/JetBrains/ruby-type-inference/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246465228,"owners_count":20781919,"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":["dynamic-analysis","ruby","rubymine","static-analysis"],"created_at":"2024-09-24T19:50:59.487Z","updated_at":"2025-03-31T12:08:43.956Z","avatar_url":"https://github.com/JetBrains.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"Automated Type Contracts Generation [![JetBrains incubator project](http://jb.gg/badges/incubator.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) [![Build Status](https://travis-ci.org/JetBrains/ruby-type-inference.svg?branch=master)](https://travis-ci.org/JetBrains/ruby-type-inference)\n===================================\n\n`ruby-type-inference` project is a completely new approach to\ntackle the problems of Ruby dynamic nature and provide more reliable\nsymbol resolution and type inference. It collects some run time data\nto build type contracts for the methods.\n\nEvery time a method is being called, some arguments of\nparticular types are being passed to it. Type Tracker collects\nall such argument combinations and then builds a special contract\nwhich satisfies all encountered argument type tuples. \n\nThe approach has its own pros and cons:\n* The obtained contracts utilize real-world usages of code of\n  any complexity so it provides true results even if a method\n  utilizes dynamic Ruby features heavily.\n* The completeness of the contracts obtained for a method highly\n  depends on the coverage of that method, including its callees.\n  That implies the need to merge the data obtained from the\n  different sources (e.g. different projects using the same gem).\n  \nThis implementation addresses the stated coverage problem by providing\nthe possibility to merge any type contracts at any time.\n     \n## Usage\n\nFor simple usage you need to install the [Ruby Dynamic Code Insight](https://plugins.jetbrains.com/plugin/10227-ruby-dynamic-code-insight) \nplugin for RubyMine. Then this plugin will require the [arg_scanner](https://rubygems.org/gems/arg_scanner) gem to be installed.\nSee [arg_scanner installation instruction](arg_scanner/README.md#installation) if you have problems while installation. \n\nAfter that, you will have the possibility to run your programs under type tracker:\n\n![Run with type tracker](screenshots/run_with_type_tracker.png)\n\nOr you can run your programs in terminal via the `rubymine-type-tracker` binary (But you have to keep your project opened \nin RubyMine). E.g.:\n```\nrubymine-type-tracker bin/rails server\n```\n\nThe `rubymine-type-tracker` binary is included into the [arg_scanner](https://rubygems.org/gems/arg_scanner) gem.\n\nSee [FEATURES.md](FEATURES.md) for understanding what benefits you will have after running your program under type tracker.\n     \n## Architecture\n \n* **arg_scanner** is a gem with a native extension to attach to \n  ruby processes and trace and intercept all method calls to log \n  type-wise data flow in runtime.\n  \n  See [`arg_scanner`] documentation for details on usage.\n\n* The [**type contract processor**](contract-creator) server listens for\n  incoming type data (from `arg_scanner`) and processes it to a compact format.\n  \n  The data stored may be used later for better code analysis and also\n  can be shared with other users.\n\n* Code analysis clients (a RubyMine/IJ+Ruby [plugin](ide-plugin)) use the contract data\n  to provide features for the users such as code completion, better resolution, etc.\n\n* (_todo_) Signature server receives contracts anonymously from the users and provides\n  a compiled contract collections for popular gems.\n\n## Running project from sources\n\n#### Prerequisites\n\nThe [`arg_scanner`] gem is used for collecting type information. It can be installed manually \nto the target SDK and requires MRI Ruby at least 2.3.\n\n#### Running type tracker\n\nThere are two possibilities to use the type tracker:\n_(I)_ using IJ/RubyMine plugin or _(II)_ requiring it from Ruby code.\n\n##### Using RubyMine plugin\n\nThe easiest way to run the plugin (and the most convenient for its development) is\nrunning it with special gradle task against IJ Ultimate snapshot:\n \n```\n./gradlew ide-plugin:runIde\n```\n\nThe task will compile the plugin, run IJ Ultimate with plugin \"installed\" in it.\nThere is no need in running anything manually in that case.\n\nIf you want to try it with existing RubyMine instance,\nyou should:\n\n1. Build it via `./gradlew ide-plugin:buildPlugin`\n2. Install plugin in the IDE\n    * Navigate to `File | Settings | Plugins | Install plugin from disk...`\n    * Locate plugin in `ide-plugin/build/distributions` and select.\n    * Restart IDE.\n\nNote that due to API changes the plugin may be incompatible with older RM instances.\n\n##### Using command line\n\n1. In order to collect the data for the script needs a contract server to be up and running;\n   it could be run by running\n   ```sh\n   ./gradlew contract-creator:runServer --args path-to-db.mv.db\n   ```\n   where `path-to-db.mv.db` is path where type contracts will be stored (H2 database file).\n\n1. Run the ruby script to be processed via [`arg-scanner`](arg_scanner/bin/arg-scanner)\n   binary.\n\n1. Use the data collected by the contract server.\n\n## Contributions\n\nAny kind of ideas, use cases, contributions and questions are very welcome\nas the project is just incubating.\nPlease feel free to create issues for any sensible request.\n\n[`arg_scanner`]: arg_scanner/README.md","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetbrains%2Fruby-type-inference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjetbrains%2Fruby-type-inference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetbrains%2Fruby-type-inference/lists"}