rubocop-sorbet 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/Gemfile.lock +2 -2
- data/config/default.yml +30 -0
- data/lib/rubocop/cop/sorbet/forbid_t_absurd.rb +31 -0
- data/lib/rubocop/cop/sorbet/forbid_t_bind.rb +31 -0
- data/lib/rubocop/cop/sorbet/forbid_t_cast.rb +31 -0
- data/lib/rubocop/cop/sorbet/forbid_t_let.rb +31 -0
- data/lib/rubocop/cop/sorbet/forbid_t_must.rb +31 -0
- data/lib/rubocop/cop/sorbet/forbid_t_type_alias.rb +30 -0
- data/lib/rubocop/cop/sorbet_cops.rb +6 -0
- data/lib/rubocop/sorbet/version.rb +1 -1
- data/manual/cops.md +6 -0
- data/manual/cops_sorbet.md +108 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79bcbc5d5d2a20065dae6bd132ce89a78f6d55d913253f582d57b26dbc90e3fe
|
4
|
+
data.tar.gz: fc68fab55a25f15a2689564842768d87b2268ed99e8bdcf503284e47dd82deb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b67f844675e5ca0c5f229cf8dd55e091f12c068dcaeb0cf289eded28a92367d32ead0f315ca4776bd0acd04e743c3c0420c345ac1ac6a7041f84dc61cc1fa78
|
7
|
+
data.tar.gz: ca77c4f1a29809ce05da20319309c760dff38fcf4adae09b60e4a588a24ca234a32c6a48226df8baa9eaa169b388953e4f65cb079a47d22f062924efdf3b9c3b
|
data/.github/workflows/ci.yml
CHANGED
@@ -16,7 +16,7 @@ jobs:
|
|
16
16
|
steps:
|
17
17
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
18
18
|
- name: Set up Ruby
|
19
|
-
uses: ruby/setup-ruby@
|
19
|
+
uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
|
20
20
|
with:
|
21
21
|
ruby-version: ${{ matrix.ruby }}
|
22
22
|
bundler-cache: true
|
@@ -31,7 +31,7 @@ jobs:
|
|
31
31
|
steps:
|
32
32
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
33
33
|
- name: Set up Ruby
|
34
|
-
uses: ruby/setup-ruby@
|
34
|
+
uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
|
35
35
|
with:
|
36
36
|
bundler-cache: true
|
37
37
|
# This is just to ensure the default config is valid. The target is intentionally set
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-sorbet (0.10.
|
4
|
+
rubocop-sorbet (0.10.4)
|
5
5
|
lint_roller
|
6
6
|
rubocop (>= 1.75.2)
|
7
7
|
|
@@ -39,7 +39,7 @@ GEM
|
|
39
39
|
regexp_parser (2.10.0)
|
40
40
|
reline (0.6.0)
|
41
41
|
io-console (~> 0.5)
|
42
|
-
rubocop (1.76.
|
42
|
+
rubocop (1.76.1)
|
43
43
|
json (~> 2.3)
|
44
44
|
language_server-protocol (~> 3.17.0.2)
|
45
45
|
lint_roller (~> 1.1.0)
|
data/config/default.yml
CHANGED
@@ -171,6 +171,36 @@ Sorbet/ForbidTStruct:
|
|
171
171
|
VersionAdded: 0.7.4
|
172
172
|
Safe: false
|
173
173
|
|
174
|
+
Sorbet/ForbidTAbsurd:
|
175
|
+
Description: 'Forbid usage of T.absurd.'
|
176
|
+
Enabled: false
|
177
|
+
VersionAdded: <<next>>
|
178
|
+
|
179
|
+
Sorbet/ForbidTBind:
|
180
|
+
Description: 'Forbid usage of T.bind.'
|
181
|
+
Enabled: false
|
182
|
+
VersionAdded: <<next>>
|
183
|
+
|
184
|
+
Sorbet/ForbidTCast:
|
185
|
+
Description: 'Forbid usage of T.cast.'
|
186
|
+
Enabled: false
|
187
|
+
VersionAdded: <<next>>
|
188
|
+
|
189
|
+
Sorbet/ForbidTLet:
|
190
|
+
Description: 'Forbid usage of T.let.'
|
191
|
+
Enabled: false
|
192
|
+
VersionAdded: <<next>>
|
193
|
+
|
194
|
+
Sorbet/ForbidTMust:
|
195
|
+
Description: 'Forbid usage of T.must.'
|
196
|
+
Enabled: false
|
197
|
+
VersionAdded: <<next>>
|
198
|
+
|
199
|
+
Sorbet/ForbidTTypeAlias:
|
200
|
+
Description: 'Forbid usage of T.type_alias.'
|
201
|
+
Enabled: false
|
202
|
+
VersionAdded: <<next>>
|
203
|
+
|
174
204
|
Sorbet/ForbidTUnsafe:
|
175
205
|
Description: 'Forbid usage of T.unsafe.'
|
176
206
|
Enabled: false
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Disallows using `T.absurd` anywhere.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# T.absurd(foo)
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# x #: absurd
|
17
|
+
class ForbidTAbsurd < RuboCop::Cop::Base
|
18
|
+
MSG = "Do not use `T.absurd`."
|
19
|
+
RESTRICT_ON_SEND = [:absurd].freeze
|
20
|
+
|
21
|
+
# @!method t_absurd?(node)
|
22
|
+
def_node_matcher(:t_absurd?, "(send (const nil? :T) :absurd _)")
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
add_offense(node) if t_absurd?(node)
|
26
|
+
end
|
27
|
+
alias_method :on_csend, :on_send
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Disallows using `T.bind` anywhere.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# T.bind(self, Integer)
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# #: self as Integer
|
17
|
+
class ForbidTBind < RuboCop::Cop::Base
|
18
|
+
MSG = "Do not use `T.bind`."
|
19
|
+
RESTRICT_ON_SEND = [:bind].freeze
|
20
|
+
|
21
|
+
# @!method t_bind?(node)
|
22
|
+
def_node_matcher(:t_bind?, "(send (const nil? :T) :bind _ _)")
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
add_offense(node) if t_bind?(node)
|
26
|
+
end
|
27
|
+
alias_method :on_csend, :on_send
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Disallows using `T.cast` anywhere.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# T.cast(foo, Integer)
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# foo #: as Integer
|
17
|
+
class ForbidTCast < RuboCop::Cop::Base
|
18
|
+
MSG = "Do not use `T.cast`."
|
19
|
+
RESTRICT_ON_SEND = [:cast].freeze
|
20
|
+
|
21
|
+
# @!method t_cast?(node)
|
22
|
+
def_node_matcher(:t_cast?, "(send (const nil? :T) :cast _ _)")
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
add_offense(node) if t_cast?(node)
|
26
|
+
end
|
27
|
+
alias_method :on_csend, :on_send
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Disallows using `T.let` anywhere.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# T.let(foo, Integer)
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# foo #: Integer
|
17
|
+
class ForbidTLet < RuboCop::Cop::Base
|
18
|
+
MSG = "Do not use `T.let`."
|
19
|
+
RESTRICT_ON_SEND = [:let].freeze
|
20
|
+
|
21
|
+
# @!method t_let?(node)
|
22
|
+
def_node_matcher(:t_let?, "(send (const nil? :T) :let _ _)")
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
add_offense(node) if t_let?(node)
|
26
|
+
end
|
27
|
+
alias_method :on_csend, :on_send
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Disallows using `T.must` anywhere.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# T.must(foo)
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# foo #: as !nil
|
17
|
+
class ForbidTMust < RuboCop::Cop::Base
|
18
|
+
MSG = "Do not use `T.must`."
|
19
|
+
RESTRICT_ON_SEND = [:must].freeze
|
20
|
+
|
21
|
+
# @!method t_must?(node)
|
22
|
+
def_node_matcher(:t_must?, "(send (const nil? :T) :must _)")
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
add_offense(node) if t_must?(node)
|
26
|
+
end
|
27
|
+
alias_method :on_csend, :on_send
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Disallows using `T.type_alias` anywhere.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# STRING_OR_INTEGER = T.type_alias { T.any(Integer, String) }
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# #: type string_or_integer = Integer | String
|
17
|
+
class ForbidTTypeAlias < RuboCop::Cop::Base
|
18
|
+
MSG = "Do not use `T.type_alias`."
|
19
|
+
|
20
|
+
# @!method t_type_alias?(node)
|
21
|
+
def_node_matcher(:t_type_alias?, "(block (call (const nil? :T) :type_alias) _ _)")
|
22
|
+
|
23
|
+
def on_block(node)
|
24
|
+
add_offense(node) if t_type_alias?(node)
|
25
|
+
end
|
26
|
+
alias_method :on_numblock, :on_block
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -14,8 +14,14 @@ require_relative "sorbet/forbid_type_aliased_shapes"
|
|
14
14
|
require_relative "sorbet/forbid_untyped_struct_props"
|
15
15
|
require_relative "sorbet/implicit_conversion_method"
|
16
16
|
require_relative "sorbet/callback_conditionals_binding"
|
17
|
+
require_relative "sorbet/forbid_t_absurd"
|
18
|
+
require_relative "sorbet/forbid_t_bind"
|
19
|
+
require_relative "sorbet/forbid_t_cast"
|
17
20
|
require_relative "sorbet/forbid_t_enum"
|
21
|
+
require_relative "sorbet/forbid_t_let"
|
22
|
+
require_relative "sorbet/forbid_t_must"
|
18
23
|
require_relative "sorbet/forbid_t_struct"
|
24
|
+
require_relative "sorbet/forbid_t_type_alias"
|
19
25
|
require_relative "sorbet/forbid_t_unsafe"
|
20
26
|
require_relative "sorbet/forbid_t_untyped"
|
21
27
|
require_relative "sorbet/redundant_extend_t_sig"
|
data/manual/cops.md
CHANGED
@@ -27,8 +27,14 @@ In the following section you find all available cops:
|
|
27
27
|
* [Sorbet/ForbidSigWithRuntime](cops_sorbet.md#sorbetforbidsigwithruntime)
|
28
28
|
* [Sorbet/ForbidSigWithoutRuntime](cops_sorbet.md#sorbetforbidsigwithoutruntime)
|
29
29
|
* [Sorbet/ForbidSuperclassConstLiteral](cops_sorbet.md#sorbetforbidsuperclassconstliteral)
|
30
|
+
* [Sorbet/ForbidTAbsurd](cops_sorbet.md#sorbetforbidtabsurd)
|
31
|
+
* [Sorbet/ForbidTBind](cops_sorbet.md#sorbetforbidtbind)
|
32
|
+
* [Sorbet/ForbidTCast](cops_sorbet.md#sorbetforbidtcast)
|
30
33
|
* [Sorbet/ForbidTEnum](cops_sorbet.md#sorbetforbidtenum)
|
34
|
+
* [Sorbet/ForbidTLet](cops_sorbet.md#sorbetforbidtlet)
|
35
|
+
* [Sorbet/ForbidTMust](cops_sorbet.md#sorbetforbidtmust)
|
31
36
|
* [Sorbet/ForbidTStruct](cops_sorbet.md#sorbetforbidtstruct)
|
37
|
+
* [Sorbet/ForbidTTypeAlias](cops_sorbet.md#sorbetforbidttypealias)
|
32
38
|
* [Sorbet/ForbidTUnsafe](cops_sorbet.md#sorbetforbidtunsafe)
|
33
39
|
* [Sorbet/ForbidTUntyped](cops_sorbet.md#sorbetforbidtuntyped)
|
34
40
|
* [Sorbet/ForbidTypeAliasedShapes](cops_sorbet.md#sorbetforbidtypealiasedshapes)
|
data/manual/cops_sorbet.md
CHANGED
@@ -632,6 +632,60 @@ Name | Default value | Configurable values
|
|
632
632
|
--- | --- | ---
|
633
633
|
Exclude | `db/migrate/*.rb` | Array
|
634
634
|
|
635
|
+
## Sorbet/ForbidTAbsurd
|
636
|
+
|
637
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
638
|
+
--- | --- | --- | --- | ---
|
639
|
+
Disabled | Yes | No | <<next>> | -
|
640
|
+
|
641
|
+
Disallows using `T.absurd` anywhere.
|
642
|
+
|
643
|
+
### Examples
|
644
|
+
|
645
|
+
```ruby
|
646
|
+
# bad
|
647
|
+
T.absurd(foo)
|
648
|
+
|
649
|
+
# good
|
650
|
+
x #: absurd
|
651
|
+
```
|
652
|
+
|
653
|
+
## Sorbet/ForbidTBind
|
654
|
+
|
655
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
656
|
+
--- | --- | --- | --- | ---
|
657
|
+
Disabled | Yes | No | <<next>> | -
|
658
|
+
|
659
|
+
Disallows using `T.bind` anywhere.
|
660
|
+
|
661
|
+
### Examples
|
662
|
+
|
663
|
+
```ruby
|
664
|
+
# bad
|
665
|
+
T.bind(self, Integer)
|
666
|
+
|
667
|
+
# good
|
668
|
+
#: self as Integer
|
669
|
+
```
|
670
|
+
|
671
|
+
## Sorbet/ForbidTCast
|
672
|
+
|
673
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
674
|
+
--- | --- | --- | --- | ---
|
675
|
+
Disabled | Yes | No | <<next>> | -
|
676
|
+
|
677
|
+
Disallows using `T.cast` anywhere.
|
678
|
+
|
679
|
+
### Examples
|
680
|
+
|
681
|
+
```ruby
|
682
|
+
# bad
|
683
|
+
T.cast(foo, Integer)
|
684
|
+
|
685
|
+
# good
|
686
|
+
foo #: as Integer
|
687
|
+
```
|
688
|
+
|
635
689
|
## Sorbet/ForbidTEnum
|
636
690
|
|
637
691
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
@@ -659,6 +713,42 @@ class MyEnum
|
|
659
713
|
end
|
660
714
|
```
|
661
715
|
|
716
|
+
## Sorbet/ForbidTLet
|
717
|
+
|
718
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
719
|
+
--- | --- | --- | --- | ---
|
720
|
+
Disabled | Yes | No | <<next>> | -
|
721
|
+
|
722
|
+
Disallows using `T.let` anywhere.
|
723
|
+
|
724
|
+
### Examples
|
725
|
+
|
726
|
+
```ruby
|
727
|
+
# bad
|
728
|
+
T.let(foo, Integer)
|
729
|
+
|
730
|
+
# good
|
731
|
+
foo #: Integer
|
732
|
+
```
|
733
|
+
|
734
|
+
## Sorbet/ForbidTMust
|
735
|
+
|
736
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
737
|
+
--- | --- | --- | --- | ---
|
738
|
+
Disabled | Yes | No | <<next>> | -
|
739
|
+
|
740
|
+
Disallows using `T.must` anywhere.
|
741
|
+
|
742
|
+
### Examples
|
743
|
+
|
744
|
+
```ruby
|
745
|
+
# bad
|
746
|
+
T.must(foo)
|
747
|
+
|
748
|
+
# good
|
749
|
+
foo #: as !nil
|
750
|
+
```
|
751
|
+
|
662
752
|
## Sorbet/ForbidTStruct
|
663
753
|
|
664
754
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
@@ -698,6 +788,24 @@ class MyStruct
|
|
698
788
|
end
|
699
789
|
```
|
700
790
|
|
791
|
+
## Sorbet/ForbidTTypeAlias
|
792
|
+
|
793
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
794
|
+
--- | --- | --- | --- | ---
|
795
|
+
Disabled | Yes | No | <<next>> | -
|
796
|
+
|
797
|
+
Disallows using `T.type_alias` anywhere.
|
798
|
+
|
799
|
+
### Examples
|
800
|
+
|
801
|
+
```ruby
|
802
|
+
# bad
|
803
|
+
STRING_OR_INTEGER = T.type_alias { T.any(Integer, String) }
|
804
|
+
|
805
|
+
# good
|
806
|
+
#: type string_or_integer = Integer | String
|
807
|
+
```
|
808
|
+
|
701
809
|
## Sorbet/ForbidTUnsafe
|
702
810
|
|
703
811
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -84,8 +84,14 @@ files:
|
|
84
84
|
- lib/rubocop/cop/sorbet/forbid_include_const_literal.rb
|
85
85
|
- lib/rubocop/cop/sorbet/forbid_mixes_in_class_methods.rb
|
86
86
|
- lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb
|
87
|
+
- lib/rubocop/cop/sorbet/forbid_t_absurd.rb
|
88
|
+
- lib/rubocop/cop/sorbet/forbid_t_bind.rb
|
89
|
+
- lib/rubocop/cop/sorbet/forbid_t_cast.rb
|
87
90
|
- lib/rubocop/cop/sorbet/forbid_t_enum.rb
|
91
|
+
- lib/rubocop/cop/sorbet/forbid_t_let.rb
|
92
|
+
- lib/rubocop/cop/sorbet/forbid_t_must.rb
|
88
93
|
- lib/rubocop/cop/sorbet/forbid_t_struct.rb
|
94
|
+
- lib/rubocop/cop/sorbet/forbid_t_type_alias.rb
|
89
95
|
- lib/rubocop/cop/sorbet/forbid_t_unsafe.rb
|
90
96
|
- lib/rubocop/cop/sorbet/forbid_t_untyped.rb
|
91
97
|
- lib/rubocop/cop/sorbet/forbid_type_aliased_shapes.rb
|