Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Sorbet for Static Type Checking #387

Merged
merged 7 commits into from
Jun 11, 2024

Conversation

delano
Copy link
Collaborator

@delano delano commented Jun 11, 2024

Implement Sorbet static type checking in the Ruby codebase to enhance code quality and reliability. This pull request includes the following commits:

  • Standardize development gems and configure require: false

  • Add type checking with Sorbet

  • Initialize Tapioca for Sorbet type checking

  • Integrate Bundler binstub for managing gem deps

The pull request also includes file changes to enable Sorbet and Tapioca, as well as documentation on how to use Sorbet and Tapioca in the project.

Please review and merge this pull request to enable static type checking and improve code safety and readability in the project.

  • Check docker image size (double check ./sorbet is not included)

Fixes #386


On merging

In the spirit of gradual adoption, we'll maintain a feature branch for Sorbet and friends to merge into as we familiarize ourselves. We'll keep it up to date with develop. That gives us the Big Plus of using Sorbet right away without the risk of making such a significant addition to the codebase.

This change removes the group declaration for development gems and instead configures each gem with require: false to avoid loading them in production. This makes the Gemfile definition more consistent and explicit about which gems are intended for development vs production use. It also addresses a linting issue by removing unused require dependencies in production code.
Sorbet was added to the Gemfile to enable static type checking of Ruby
code. This will help catch errors earlier and improve code quality.

To enable type checking:

- Sorbet was added as a development dependency
- Gemfile.lock was updated to resolve dependencies

With Sorbet integrated, future work can begin gradually adding type
annotations to codebases to take greater advantage of the static
analysis it provides. This helps prevent bugs and ensures code behaves
as intended.
`bundle exec tapioca init`

- Generates Tapioca configuration files, setting up the project for RBI
generation.
- Creates initial RBI files for gems specified in the Gemfile, aiding
Sorbet in type checking external library usage.
- If Sorbet is not already initialized, runs `srb init` to set up
Sorbet, including generating RBI files for Ruby standard library and
project code.
- May also include documentation or examples on using Tapioca and Sorbet
within the project.
`bundle binstubs bundler` creates a `bin/bundler` script that can be
used to manage gem dependencies.
@delano delano added improvement Issues or pull requests that involve improvements to the project. security Issues or pull requests related to security. labels Jun 11, 2024
@delano delano self-assigned this Jun 11, 2024
@delano delano added documentation Issues or pull requests related to documentation. tech debt Addressing future rework costs due to quick, suboptimal solutions taken previously. maintenance Issues or tasks related to maintenance of the project. tests Issues or pull requests that involve testing code. Review effort [1-5]: 3 Pull requests that require a higher level of review effort. dx Developer experience working with the project. labels Jun 11, 2024
@delano delano linked an issue Jun 11, 2024 that may be closed by this pull request
2 tasks
It's large and not in charge of anything in the Docker build process.
@delano delano marked this pull request as ready for review June 11, 2024 08:17
Also use snakecase to appease Rubocop.
@delano delano changed the base branch from develop to feature/286-typed June 11, 2024 18:23
@delano delano merged commit 224183a into feature/typed Jun 11, 2024
6 checks passed
@delano delano deleted the 386-integrate-sorbet-for-static-type-checking branch June 11, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues or pull requests related to documentation. dx Developer experience working with the project. improvement Issues or pull requests that involve improvements to the project. maintenance Issues or tasks related to maintenance of the project. Review effort [1-5]: 3 Pull requests that require a higher level of review effort. security Issues or pull requests related to security. tech debt Addressing future rework costs due to quick, suboptimal solutions taken previously. tests Issues or pull requests that involve testing code.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Integrate Sorbet for Static Type Checking
1 participant