Skip to content

Commit

Permalink
Remove Sorbet typechecker
Browse files Browse the repository at this point in the history
**What does this PR do?**:

This PR is spiritually a revert of #1607, when we added the Sorbet
typechecker to dd-trace-rb.

It includes two commits: One where we remove all configuration
and scaffolding surrounding Sorbet, and one where we remove all of the
`# typed: ...` magic comments and `include Kernel` definitions added
to make Sorbet happy.

**Motivation**:

As documented in #2641, the team has decided that the value vs pain
equation for Sorbet has shifted in the past months, and thus that
it was time to remove Sorbet.

**Additional Notes**:

Sorbet type checking in CI was actually removed earlier this week in
 #2617.

**How to test the change?**:

CI should still be green.
  • Loading branch information
ivoanjo committed Feb 24, 2023
1 parent 484d0c1 commit ec45215
Show file tree
Hide file tree
Showing 75 changed files with 5 additions and 41,397 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
gemfiles/**/* linguist-generated=true
sorbet/rbi/**/* linguist-generated=true
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docs:

# Only test changes
dev/testing:
- all: [ '{spec/**,integration/**,benchmarks/**,sorbet/**}' ]
- all: [ '{spec/**,integration/**,benchmarks/**}' ]

# Changes to Profiling
profiling:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,3 @@ gemfiles/.bundle
# Native extension binaries
lib/*.bundle
lib/*.so

# Extra file kept by sorbet for debugging usage, as documented in https://sorbet.org/docs/adopting#step-6-source-control
sorbet/rbi/hidden-definitions/errors.txt
2 changes: 0 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ REMOVED_GEMS = {
:check => [
'rbs',
'steep',
'spoom',
'sorbet',
],
}

Expand Down
11 changes: 0 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,6 @@ if RUBY_PLATFORM != 'java'
end

group :check do
# For type checking
# Sorbet releases almost daily, with new checks introduced that can make a
# previously-passing codebase start failing. Thus, we need to lock to a specific
# version and bump it from time to time.
# Also, there's no support for windows
if RUBY_VERSION >= '2.4.0' && (RUBY_PLATFORM =~ /^x86_64-(darwin|linux)/)
gem 'sorbet', '= 0.5.10201'
gem 'spoom', '~> 1.1'
end

# type checking with steep
if RUBY_VERSION >= '2.6.0' && RUBY_PLATFORM != 'java'
gem 'rbs', '~> 2.8.1', require: false
gem 'steep', '~> 1.3.0', require: false
Expand Down
34 changes: 3 additions & 31 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -467,36 +467,8 @@ Rake::ExtensionTask.new("ddtrace_profiling_loader.#{RUBY_VERSION}_#{RUBY_PLATFOR
ext.ext_dir = 'ext/ddtrace_profiling_loader'
end

desc 'Runs the sorbet type checker on the codebase'
task :typecheck do
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0')
$stderr.puts 'Sorry, cannot run sorbet type checker on older rubies :(' # rubocop:disable Style/StderrPuts
else
begin
sh 'srb tc'
rescue
$stderr.puts( # rubocop:disable Style/StderrPuts
%(
+------------------------------------------------------------------------------+
| **Hello there, fellow contributor who just triggered a Sorbet type error** |
| |
| We're still experimenting with Sorbet on this codebase. If possible, take a |
| stab at getting it to work, but feel free to unblock yourself by adding |
| a `# typed: false` or `# typed: ignore` comment at the top of files which |
| Sorbet is struggling with. |
| |
| In particular, if you're adding a new integration, you'll need to use this |
| mechanism as Sorbet does not play well with optional dependencies. |
+------------------------------------------------------------------------------+
)
)
raise
end
end
end

desc 'Runs rubocop + type check + main test suite'
task default: ['rubocop', 'typecheck', 'spec:main']
desc 'Runs rubocop + main test suite'
task default: ['rubocop', 'spec:main']

desc 'Runs the default task in parallel'
multitask fastdefault: ['rubocop', 'typecheck', 'spec:main']
multitask fastdefault: ['rubocop', 'spec:main']
14 changes: 0 additions & 14 deletions docs/DevelopmentGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ This guide covers some of the common how-tos and technical reference material fo
- [Running tests](#running-tests)
- [Checking code quality](#checking-code-quality)
- [Running benchmarks](#running-benchmarks)
- [Type checking](#type-checking)
- [Appendix](#appendix)
- [Writing new integrations](#writing-new-integrations)
- [Custom transport adapters](#custom-transport-adapters)
Expand Down Expand Up @@ -164,19 +163,6 @@ $ bundle exec appraisal ruby-3.0.4-contrib rake spec:benchmark

Results are printed to STDOUT as well as written to the `./tmp/benchmark/` directory.

## Type checking

This library uses the [Sorbet](https://sorbet.org/) type checker. Sorbet can be run with `bundle exec srb tc` (or `bundle exec rake
typecheck`). There's also Language Server Protocol support, if your editor supports it.

Type checking can be controlled on a file-by-file manner, using a `# typed: ...` comment. The default (when none is provided) is assuming `# typed: false`.

Things to note:

* For compatibility with older Rubies, we use Sorbet but do not yet allow type annotations in the codebase. If Sorbet is blocking you, feel free to use `# typed: false` or `# typed: ignore` with a quick note on why this was needed. In many cases, Sorbet can typecheck a file correctly with no extra type annotations.

* Most integration-specific code will reference optional external dependencies which Sorbet cannot see into. You'll probably need to use `# typed: false` or `# typed: ignore` for those files as well.

## Appendix

### Writing new integrations
Expand Down
7 changes: 0 additions & 7 deletions sorbet/config

This file was deleted.

197 changes: 0 additions & 197 deletions sorbet/rbi/gems/addressable.rbi

This file was deleted.

Loading

0 comments on commit ec45215

Please sign in to comment.