Skip to content

Commit

Permalink
Mark callback binding cop as unsafe and disable it by default
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Oct 21, 2021
1 parent 076602f commit ebe2705
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Sorbet/BindingConstantWithoutTypeAlias:

Sorbet/CallbackConditionalsBinding:
Description: 'Ensures callback conditionals are bound to the right type.'
Enabled: true
Enabled: false
Safe: false
VersionAdded: 0.7.0

Sorbet/CheckedTrueInSignature:
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/sorbet/callback_conditionals_binding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module Sorbet
# This cop ensures that callback conditionals are bound to the right type
# so that they are type checked properly.
#
# Auto-correction is unsafe because other libraries define similar style callbacks as Rails, but don't always need
# binding to the attached class. Auto-correcting those usages can lead to false positives and auto-corretion
# introduces new typing errors.
#
# @example
#
# # bad
Expand Down
6 changes: 5 additions & 1 deletion manual/cops_sorbet.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ FooOrBar = T.type_alias { T.any(Foo, Bar) }

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | Yes | 0.7.0 | -
Disabled | No | Yes | 0.7.0 | -

This cop ensures that callback conditionals are bound to the right type
so that they are type checked properly.

Auto-correction is unsafe because other libraries define similar style callbacks as Rails, but don't always need
binding to the attached class. Auto-correcting those usages can lead to false positives and auto-corretion
introduces new typing errors.

### Examples

```ruby
Expand Down

0 comments on commit ebe2705

Please sign in to comment.