Skip to content

Commit

Permalink
Merge pull request #268 from corsonknowles/strict_sigil_safety_declar…
Browse files Browse the repository at this point in the history
…ation

Set `Sorbet/StrictSigil` to `Safe: false`
  • Loading branch information
egiurleo authored Nov 18, 2024
2 parents ad91cb3 + 92c7457 commit eef0497
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rubocop-sorbet (0.8.7)
rubocop-sorbet (0.8.8)
rubocop (>= 1)

GEM
Expand Down
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ Sorbet/SingleLineRbiClassModuleDefinitions:
Sorbet/StrictSigil:
Description: 'All files must be at least at strictness `strict`.'
Enabled: false
Safe: false
SuggestedStrictness: "strict"
VersionAdded: 0.3.3
Include:
Expand Down
1 change: 1 addition & 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,7 @@ module Sorbet
# Ensures that callback conditionals are bound to the right type
# so that they are type checked properly.
#
# @safety
# 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-correction
# introduces new typing errors.
Expand Down
15 changes: 15 additions & 0 deletions lib/rubocop/cop/sorbet/sigils/strict_sigil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ module RuboCop
module Cop
module Sorbet
# Makes the Sorbet `strict` sigil mandatory in all files.
#
# @safety
# This cop is unsafe because Sorbet sigils may not exist yet when it is run.
#
# @example
#
# # bad
# # typed: true
#
# # bad
# # typed: false
#
# # good
# # typed: strict
#
class StrictSigil < HasSigil
def minimum_strictness
"strict"
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/sorbet/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module RuboCop
module Sorbet
VERSION = "0.8.7"
VERSION = "0.8.8"
end
end
15 changes: 14 additions & 1 deletion manual/cops_sorbet.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,23 @@ Include | `**/*.rbi` | Array
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Disabled | Yes | Yes | 0.3.3 | -
Disabled | No | Yes | 0.3.3 | -
Makes the Sorbet `strict` sigil mandatory in all files.
### Examples
```ruby
# bad
# typed: true
# bad
# typed: false
# good
# typed: strict
```
### Configurable attributes
Name | Default value | Configurable values
Expand Down

0 comments on commit eef0497

Please sign in to comment.