rubocop-sorbet 0.8.9 → 0.10.0
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 +1 -1
- data/Gemfile.lock +10 -8
- data/README.md +10 -5
- data/config/default.yml +17 -1
- data/config/rbi.yml +3 -3
- data/lib/rubocop/cop/sorbet/constants_from_strings.rb +1 -0
- data/lib/rubocop/cop/sorbet/mixin/signature_help.rb +20 -7
- data/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb +19 -1
- data/lib/rubocop/cop/sorbet/signatures/forbid_sig.rb +34 -0
- data/lib/rubocop/cop/sorbet/signatures/forbid_sig_with_runtime.rb +34 -0
- data/lib/rubocop/cop/sorbet/signatures/forbid_sig_without_runtime.rb +40 -0
- data/lib/rubocop/cop/sorbet_cops.rb +6 -3
- data/lib/rubocop/sorbet/plugin.rb +38 -0
- data/lib/rubocop/sorbet/version.rb +1 -1
- data/lib/rubocop/sorbet.rb +10 -5
- data/lib/rubocop-sorbet.rb +5 -2
- data/manual/cops.md +3 -0
- data/manual/cops_sorbet.md +72 -0
- data/rubocop-sorbet.gemspec +1 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc64043160fbb424294446cc5433eb9134d6b4dec111f858dcd759d3e2bd3b10
|
4
|
+
data.tar.gz: 9f1f4fbacdcf92361cad0e52f5de2301b50ce6ac6d14c026a7508bd82f69e4bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfd751a32647db87a95f58e8ec04ad2bd21042d527f85c228abb327255e9f7a5c0ae40206b3f228d6eb4a162a91910c4215339fb19613e9c81700f11a745e032
|
7
|
+
data.tar.gz: 9e3dfc82ca705a74c52e6a8345b5e986bc0e66e8bedeb10f5d0ba4e65fa86e82afcd96e3eca41fb336ad903935e850f60335b346f9305f6b56fd97c9e4953ffd
|
data/.github/workflows/ci.yml
CHANGED
@@ -38,7 +38,7 @@ jobs:
|
|
38
38
|
# to a directory that doesn't contain any .rb or .rbi files.
|
39
39
|
- name: Validate default config
|
40
40
|
run: |
|
41
|
-
bin/rubocop --config config/rbi.yml config
|
41
|
+
bin/rubocop --plugin rubocop-sorbet --config config/rbi.yml config
|
42
42
|
bin/rubocop --config config/default.yml config -r rubocop-sorbet
|
43
43
|
- name: Lint Ruby files
|
44
44
|
run: bin/rubocop
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-sorbet (0.
|
4
|
+
rubocop-sorbet (0.10.0)
|
5
5
|
rubocop (>= 1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
ast (2.4.
|
10
|
+
ast (2.4.3)
|
11
11
|
date (3.4.1)
|
12
12
|
debug (1.10.0)
|
13
13
|
irb (~> 1.10)
|
@@ -17,13 +17,14 @@ GEM
|
|
17
17
|
irb (1.14.3)
|
18
18
|
rdoc (>= 4.0.0)
|
19
19
|
reline (>= 0.4.2)
|
20
|
-
json (2.10.
|
20
|
+
json (2.10.2)
|
21
21
|
language_server-protocol (3.17.0.4)
|
22
22
|
lint_roller (1.1.0)
|
23
23
|
parallel (1.26.3)
|
24
|
-
parser (3.3.7.
|
24
|
+
parser (3.3.7.4)
|
25
25
|
ast (~> 2.4.1)
|
26
26
|
racc
|
27
|
+
prism (1.4.0)
|
27
28
|
psych (5.2.2)
|
28
29
|
date
|
29
30
|
stringio
|
@@ -48,7 +49,7 @@ GEM
|
|
48
49
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
50
|
rspec-support (~> 3.13.0)
|
50
51
|
rspec-support (3.13.1)
|
51
|
-
rubocop (1.
|
52
|
+
rubocop (1.75.1)
|
52
53
|
json (~> 2.3)
|
53
54
|
language_server-protocol (~> 3.17.0.2)
|
54
55
|
lint_roller (~> 1.1.0)
|
@@ -56,11 +57,12 @@ GEM
|
|
56
57
|
parser (>= 3.3.0.2)
|
57
58
|
rainbow (>= 2.2.2, < 4.0)
|
58
59
|
regexp_parser (>= 2.9.3, < 3.0)
|
59
|
-
rubocop-ast (>= 1.
|
60
|
+
rubocop-ast (>= 1.43.0, < 2.0)
|
60
61
|
ruby-progressbar (~> 1.7)
|
61
62
|
unicode-display_width (>= 2.4.0, < 4.0)
|
62
|
-
rubocop-ast (1.
|
63
|
-
parser (>= 3.3.
|
63
|
+
rubocop-ast (1.43.0)
|
64
|
+
parser (>= 3.3.7.2)
|
65
|
+
prism (~> 1.4)
|
64
66
|
rubocop-shopify (2.15.1)
|
65
67
|
rubocop (~> 1.51)
|
66
68
|
ruby-progressbar (1.13.0)
|
data/README.md
CHANGED
@@ -24,30 +24,33 @@ You need to tell RuboCop to load the Sorbet extension. There are three ways to d
|
|
24
24
|
Put this into your `.rubocop.yml`:
|
25
25
|
|
26
26
|
```yaml
|
27
|
-
|
27
|
+
plugins: rubocop-sorbet
|
28
28
|
```
|
29
29
|
|
30
30
|
Alternatively, use the following array notation when specifying multiple extensions:
|
31
31
|
|
32
32
|
```yaml
|
33
|
-
|
34
|
-
- rubocop-other-extension
|
33
|
+
plugins:
|
35
34
|
- rubocop-sorbet
|
35
|
+
- rubocop-other-extension
|
36
36
|
```
|
37
37
|
|
38
38
|
Now you can run `rubocop` and it will automatically load the RuboCop Sorbet cops together with the standard cops.
|
39
39
|
|
40
|
+
> [!NOTE]
|
41
|
+
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
|
42
|
+
|
40
43
|
### Command line
|
41
44
|
|
42
45
|
```sh
|
43
|
-
rubocop --
|
46
|
+
rubocop --plugin rubocop-sorbet
|
44
47
|
```
|
45
48
|
|
46
49
|
### Rake task
|
47
50
|
|
48
51
|
```ruby
|
49
52
|
RuboCop::RakeTask.new do |task|
|
50
|
-
task.
|
53
|
+
task.plugins << 'rubocop-sorbet'
|
51
54
|
end
|
52
55
|
```
|
53
56
|
|
@@ -59,6 +62,8 @@ To enable the cops related to RBI files under the `sorbet/rbi/` directory, put t
|
|
59
62
|
inherit_gem:
|
60
63
|
rubocop-sorbet: config/rbi.yml
|
61
64
|
```
|
65
|
+
> [!NOTE]
|
66
|
+
> If your top-level `.rubocop.yml` does not load `rubocop-sorbet`, you might need to also add a `require: rubocop-sorbet` or `plugins: rubocop-sorbet` to the `sorbet/rbi/.rubocop.yml` file at the top.
|
62
67
|
|
63
68
|
This will turn off default cops for `**/*.rbi` files and enable the RBI specific cops.
|
64
69
|
|
data/config/default.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Sorbet/Refinement:
|
2
|
-
Description: >-
|
2
|
+
Description: >-
|
3
3
|
Checks for the use of Ruby Refinements library. Refinements add
|
4
4
|
complexity and incur a performance penalty that can be significant
|
5
5
|
for large code bases. They are also not supported by Sorbet.
|
@@ -60,6 +60,7 @@ Sorbet/EnforceSingleSigil:
|
|
60
60
|
Sorbet/EnforceSignatures:
|
61
61
|
Description: 'Ensures all methods have a valid signature.'
|
62
62
|
Enabled: false
|
63
|
+
AllowRBS: false
|
63
64
|
VersionAdded: 0.3.4
|
64
65
|
|
65
66
|
Sorbet/FalseSigil:
|
@@ -102,6 +103,21 @@ Sorbet/ForbidTypeAliasedShapes:
|
|
102
103
|
Enabled: false
|
103
104
|
VersionAdded: 0.7.6
|
104
105
|
|
106
|
+
Sorbet/ForbidSig:
|
107
|
+
Description: 'Forbid usage of sig'
|
108
|
+
Enabled: false
|
109
|
+
VersionAdded: <<next>>
|
110
|
+
|
111
|
+
Sorbet/ForbidSigWithRuntime:
|
112
|
+
Description: 'Forbid usage of T::Sig.sig'
|
113
|
+
Enabled: false
|
114
|
+
VersionAdded: <<next>>
|
115
|
+
|
116
|
+
Sorbet/ForbidSigWithoutRuntime:
|
117
|
+
Description: 'Forbid usage of T::Sig::WithoutRuntime.sig'
|
118
|
+
Enabled: false
|
119
|
+
VersionAdded: <<next>>
|
120
|
+
|
105
121
|
Sorbet/ForbidSuperclassConstLiteral:
|
106
122
|
Description: 'Forbid superclasses which are non-literal constants.'
|
107
123
|
Enabled: false
|
data/config/rbi.yml
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-sorbet
|
3
|
-
|
4
1
|
AllCops:
|
5
2
|
DisabledByDefault: true
|
6
3
|
Include:
|
@@ -199,6 +196,9 @@ Lint/Syntax:
|
|
199
196
|
|
200
197
|
## Sorbet
|
201
198
|
|
199
|
+
Sorbet/ForbidSigWithoutRuntime:
|
200
|
+
Enabled: true
|
201
|
+
|
202
202
|
Sorbet/EnforceSigilOrder:
|
203
203
|
Enabled: true
|
204
204
|
|
@@ -9,21 +9,34 @@ module RuboCop
|
|
9
9
|
|
10
10
|
# @!method signature?(node)
|
11
11
|
def_node_matcher(:signature?, <<~PATTERN)
|
12
|
+
{#bare_sig? #sig_with_runtime? #sig_without_runtime?}
|
13
|
+
PATTERN
|
14
|
+
|
15
|
+
# @!method bare_sig?(node)
|
16
|
+
def_node_matcher(:bare_sig?, <<~PATTERN)
|
12
17
|
(block (send
|
13
|
-
|
18
|
+
nil?
|
14
19
|
:sig
|
15
20
|
(sym :final)?
|
16
21
|
) (args) ...)
|
17
22
|
PATTERN
|
18
23
|
|
19
|
-
# @!method
|
20
|
-
def_node_matcher(:
|
21
|
-
(
|
24
|
+
# @!method sig_with_runtime?(node)
|
25
|
+
def_node_matcher(:sig_with_runtime?, <<~PATTERN)
|
26
|
+
(block (send
|
27
|
+
(const (const {nil? cbase} :T) :Sig)
|
28
|
+
:sig
|
29
|
+
(sym :final)?
|
30
|
+
) (args) ...)
|
22
31
|
PATTERN
|
23
32
|
|
24
|
-
# @!method
|
25
|
-
def_node_matcher(:
|
26
|
-
(
|
33
|
+
# @!method sig_without_runtime?(node)
|
34
|
+
def_node_matcher(:sig_without_runtime?, <<~PATTERN)
|
35
|
+
(block (send
|
36
|
+
(const (const (const {nil? cbase} :T) :Sig) :WithoutRuntime)
|
37
|
+
:sig
|
38
|
+
(sym :final)?
|
39
|
+
) (args) ...)
|
27
40
|
PATTERN
|
28
41
|
|
29
42
|
def on_block(node)
|
@@ -28,6 +28,8 @@ module RuboCop
|
|
28
28
|
extend AutoCorrector
|
29
29
|
include SignatureHelp
|
30
30
|
|
31
|
+
RBS_COMMENT_REGEX = /^#:.*$/
|
32
|
+
|
31
33
|
def initialize(config = nil, options = nil)
|
32
34
|
super(config, options)
|
33
35
|
@last_sig_for_scope = {}
|
@@ -65,7 +67,7 @@ module RuboCop
|
|
65
67
|
|
66
68
|
def check_node(node)
|
67
69
|
scope = self.scope(node)
|
68
|
-
unless @last_sig_for_scope[scope]
|
70
|
+
unless @last_sig_for_scope[scope] || has_rbs_comment?(node)
|
69
71
|
add_offense(
|
70
72
|
node,
|
71
73
|
message: "Each method is required to have a signature.",
|
@@ -76,6 +78,22 @@ module RuboCop
|
|
76
78
|
@last_sig_for_scope[scope] = nil
|
77
79
|
end
|
78
80
|
|
81
|
+
def has_rbs_comment?(node)
|
82
|
+
return false unless cop_config["AllowRBS"] == true
|
83
|
+
|
84
|
+
node = node.parent while RuboCop::AST::SendNode === node.parent
|
85
|
+
return false if (comments = preceeding_comments(node)).empty?
|
86
|
+
|
87
|
+
last_comment = comments.last
|
88
|
+
return false if last_comment.loc.line + 1 < node.loc.line
|
89
|
+
|
90
|
+
comments.any? { |comment| RBS_COMMENT_REGEX.match?(comment.text) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def preceeding_comments(node)
|
94
|
+
processed_source.ast_with_comments[node].select { |comment| comment.loc.line < node.loc.line }
|
95
|
+
end
|
96
|
+
|
79
97
|
def autocorrect(corrector, node)
|
80
98
|
suggest = SigSuggestion.new(node.loc.column, param_type_placeholder, return_type_placeholder)
|
81
99
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "stringio"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Check that definitions do not use a `sig` block.
|
9
|
+
#
|
10
|
+
# Good:
|
11
|
+
#
|
12
|
+
# ```
|
13
|
+
# #: -> void
|
14
|
+
# def foo; end
|
15
|
+
# ```
|
16
|
+
#
|
17
|
+
# Bad:
|
18
|
+
#
|
19
|
+
# ```
|
20
|
+
# sig { void }
|
21
|
+
# def foo; end
|
22
|
+
# ```
|
23
|
+
class ForbidSig < ::RuboCop::Cop::Base
|
24
|
+
include SignatureHelp
|
25
|
+
|
26
|
+
MSG = "Do not use `T::Sig`."
|
27
|
+
|
28
|
+
def on_signature(node)
|
29
|
+
add_offense(node) if bare_sig?(node)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "stringio"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Check that definitions do not use a `sig` block.
|
9
|
+
#
|
10
|
+
# Good:
|
11
|
+
#
|
12
|
+
# ```
|
13
|
+
# #: -> void
|
14
|
+
# def foo; end
|
15
|
+
# ```
|
16
|
+
#
|
17
|
+
# Bad:
|
18
|
+
#
|
19
|
+
# ```
|
20
|
+
# T::Sig.sig { void }
|
21
|
+
# def foo; end
|
22
|
+
# ```
|
23
|
+
class ForbidSigWithRuntime < ::RuboCop::Cop::Base
|
24
|
+
include SignatureHelp
|
25
|
+
|
26
|
+
MSG = "Do not use `T::Sig.sig`."
|
27
|
+
|
28
|
+
def on_signature(node)
|
29
|
+
add_offense(node) if sig_with_runtime?(node)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "stringio"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# Check that `sig` is used instead of `T::Sig::WithoutRuntime.sig`.
|
9
|
+
#
|
10
|
+
# Good:
|
11
|
+
#
|
12
|
+
# ```
|
13
|
+
# sig { void }
|
14
|
+
# def foo; end
|
15
|
+
# ```
|
16
|
+
#
|
17
|
+
# Bad:
|
18
|
+
#
|
19
|
+
# ```
|
20
|
+
# T::Sig::WithoutRuntime.sig { void }
|
21
|
+
# def foo; end
|
22
|
+
# ```
|
23
|
+
class ForbidSigWithoutRuntime < ::RuboCop::Cop::Base
|
24
|
+
include SignatureHelp
|
25
|
+
extend AutoCorrector
|
26
|
+
|
27
|
+
MSG = "Do not use `T::Sig::WithoutRuntime.sig`."
|
28
|
+
|
29
|
+
def on_signature(node)
|
30
|
+
return unless sig_without_runtime?(node)
|
31
|
+
|
32
|
+
sig = node.children[0]
|
33
|
+
add_offense(sig) do |corrector|
|
34
|
+
corrector.replace(sig, sig.source.gsub(/T\s*::\s*Sig\s*::\s*WithoutRuntime\s*\.\s*/m, ""))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -31,11 +31,14 @@ require_relative "sorbet/rbi_versioning/valid_gem_version_annotations"
|
|
31
31
|
|
32
32
|
require_relative "sorbet/signatures/allow_incompatible_override"
|
33
33
|
require_relative "sorbet/signatures/checked_true_in_signature"
|
34
|
-
require_relative "sorbet/signatures/
|
34
|
+
require_relative "sorbet/signatures/empty_line_after_sig"
|
35
|
+
require_relative "sorbet/signatures/enforce_signatures"
|
36
|
+
require_relative "sorbet/signatures/forbid_sig"
|
37
|
+
require_relative "sorbet/signatures/forbid_sig_with_runtime"
|
38
|
+
require_relative "sorbet/signatures/forbid_sig_without_runtime"
|
35
39
|
require_relative "sorbet/signatures/keyword_argument_ordering"
|
36
40
|
require_relative "sorbet/signatures/signature_build_order"
|
37
|
-
require_relative "sorbet/signatures/
|
38
|
-
require_relative "sorbet/signatures/empty_line_after_sig"
|
41
|
+
require_relative "sorbet/signatures/void_checked_tests"
|
39
42
|
|
40
43
|
require_relative "sorbet/sigils/valid_sigil"
|
41
44
|
require_relative "sorbet/sigils/has_sigil"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
rubocop_min_version = Gem::Version.create("1.72.1")
|
4
|
+
rubocop_version = Gem::Version.create(RuboCop::Version.version)
|
5
|
+
|
6
|
+
return if rubocop_version < rubocop_min_version
|
7
|
+
|
8
|
+
require "rubocop"
|
9
|
+
require "lint_roller"
|
10
|
+
require "pathname"
|
11
|
+
|
12
|
+
module RuboCop
|
13
|
+
module Sorbet
|
14
|
+
# A plugin that integrates RuboCop Sorbet with RuboCop's plugin system.
|
15
|
+
class Plugin < LintRoller::Plugin
|
16
|
+
def about
|
17
|
+
LintRoller::About.new(
|
18
|
+
name: "rubocop-sorbet",
|
19
|
+
version: VERSION,
|
20
|
+
homepage: "https://github.com/Shopify/rubocop-sorbet",
|
21
|
+
description: "A collection of Rubocop rules for Sorbet.",
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def supported?(context)
|
26
|
+
context.engine == :rubocop
|
27
|
+
end
|
28
|
+
|
29
|
+
def rules(_context)
|
30
|
+
project_root = Pathname.new(__dir__).join("../../..")
|
31
|
+
|
32
|
+
ConfigObsoletion.files << project_root.join("config", "obsoletion.yml")
|
33
|
+
|
34
|
+
LintRoller::Rules.new(type: :path, config_format: :rubocop, value: project_root.join("config", "default.yml"))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/rubocop/sorbet.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "rubocop"
|
3
4
|
require "rubocop/sorbet/version"
|
5
|
+
require "rubocop/sorbet/plugin"
|
6
|
+
require "pathname"
|
4
7
|
require "yaml"
|
5
8
|
|
6
9
|
module RuboCop
|
7
10
|
module Sorbet
|
8
11
|
class Error < StandardError; end
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
unless defined?(::RuboCop::Sorbet::Plugin)
|
14
|
+
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
15
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze
|
16
|
+
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
13
17
|
|
14
|
-
|
18
|
+
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
15
19
|
|
16
|
-
|
20
|
+
::RuboCop::ConfigObsoletion.files << PROJECT_ROOT.join("config", "obsoletion.yml")
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
data/lib/rubocop-sorbet.rb
CHANGED
@@ -4,8 +4,11 @@ require "rubocop"
|
|
4
4
|
|
5
5
|
require_relative "rubocop/sorbet"
|
6
6
|
require_relative "rubocop/sorbet/version"
|
7
|
-
require_relative "rubocop/sorbet/
|
7
|
+
require_relative "rubocop/sorbet/plugin"
|
8
8
|
|
9
|
-
RuboCop::Sorbet::
|
9
|
+
unless defined?(RuboCop::Sorbet::Plugin)
|
10
|
+
require_relative "rubocop/sorbet/inject"
|
11
|
+
RuboCop::Sorbet::Inject.defaults!
|
12
|
+
end
|
10
13
|
|
11
14
|
require_relative "rubocop/cop/sorbet_cops"
|
data/manual/cops.md
CHANGED
@@ -20,6 +20,9 @@ In the following section you find all available cops:
|
|
20
20
|
* [Sorbet/ForbidExtendTSigHelpersInShims](cops_sorbet.md#sorbetforbidextendtsighelpersinshims)
|
21
21
|
* [Sorbet/ForbidIncludeConstLiteral](cops_sorbet.md#sorbetforbidincludeconstliteral)
|
22
22
|
* [Sorbet/ForbidRBIOutsideOfAllowedPaths](cops_sorbet.md#sorbetforbidrbioutsideofallowedpaths)
|
23
|
+
* [Sorbet/ForbidSig](cops_sorbet.md#sorbetforbidsig)
|
24
|
+
* [Sorbet/ForbidSigWithRuntime](cops_sorbet.md#sorbetforbidsigwithruntime)
|
25
|
+
* [Sorbet/ForbidSigWithoutRuntime](cops_sorbet.md#sorbetforbidsigwithoutruntime)
|
23
26
|
* [Sorbet/ForbidSuperclassConstLiteral](cops_sorbet.md#sorbetforbidsuperclassconstliteral)
|
24
27
|
* [Sorbet/ForbidTEnum](cops_sorbet.md#sorbetforbidtenum)
|
25
28
|
* [Sorbet/ForbidTStruct](cops_sorbet.md#sorbetforbidtstruct)
|
data/manual/cops_sorbet.md
CHANGED
@@ -254,6 +254,12 @@ You can configure the placeholders used by changing the following options:
|
|
254
254
|
* `ParameterTypePlaceholder`: placeholders used for parameter types (default: 'T.untyped')
|
255
255
|
* `ReturnTypePlaceholder`: placeholders used for return types (default: 'T.untyped')
|
256
256
|
|
257
|
+
### Configurable attributes
|
258
|
+
|
259
|
+
Name | Default value | Configurable values
|
260
|
+
--- | --- | ---
|
261
|
+
AllowRBS | `false` | Boolean
|
262
|
+
|
257
263
|
## Sorbet/EnforceSingleSigil
|
258
264
|
|
259
265
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
@@ -417,6 +423,72 @@ Name | Default value | Configurable values
|
|
417
423
|
AllowedPaths | `rbi/**`, `sorbet/rbi/**` | Array
|
418
424
|
Include | `**/*.rbi` | Array
|
419
425
|
|
426
|
+
## Sorbet/ForbidSig
|
427
|
+
|
428
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
429
|
+
--- | --- | --- | --- | ---
|
430
|
+
Disabled | Yes | No | <<next>> | -
|
431
|
+
|
432
|
+
Check that definitions do not use a `sig` block.
|
433
|
+
|
434
|
+
Good:
|
435
|
+
|
436
|
+
```
|
437
|
+
#: -> void
|
438
|
+
def foo; end
|
439
|
+
```
|
440
|
+
|
441
|
+
Bad:
|
442
|
+
|
443
|
+
```
|
444
|
+
sig { void }
|
445
|
+
def foo; end
|
446
|
+
```
|
447
|
+
|
448
|
+
## Sorbet/ForbidSigWithRuntime
|
449
|
+
|
450
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
451
|
+
--- | --- | --- | --- | ---
|
452
|
+
Disabled | Yes | No | <<next>> | -
|
453
|
+
|
454
|
+
Check that definitions do not use a `sig` block.
|
455
|
+
|
456
|
+
Good:
|
457
|
+
|
458
|
+
```
|
459
|
+
#: -> void
|
460
|
+
def foo; end
|
461
|
+
```
|
462
|
+
|
463
|
+
Bad:
|
464
|
+
|
465
|
+
```
|
466
|
+
T::Sig.sig { void }
|
467
|
+
def foo; end
|
468
|
+
```
|
469
|
+
|
470
|
+
## Sorbet/ForbidSigWithoutRuntime
|
471
|
+
|
472
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
473
|
+
--- | --- | --- | --- | ---
|
474
|
+
Disabled | Yes | Yes | <<next>> | -
|
475
|
+
|
476
|
+
Check that `sig` is used instead of `T::Sig::WithoutRuntime.sig`.
|
477
|
+
|
478
|
+
Good:
|
479
|
+
|
480
|
+
```
|
481
|
+
sig { void }
|
482
|
+
def foo; end
|
483
|
+
```
|
484
|
+
|
485
|
+
Bad:
|
486
|
+
|
487
|
+
```
|
488
|
+
T::Sig::WithoutRuntime.sig { void }
|
489
|
+
def foo; end
|
490
|
+
```
|
491
|
+
|
420
492
|
## Sorbet/ForbidSuperclassConstLiteral
|
421
493
|
|
422
494
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
data/rubocop-sorbet.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
19
|
spec.metadata["source_code_uri"] = "https://github.com/shopify/rubocop-sorbet"
|
20
|
+
spec.metadata["default_lint_roller_plugin"] = "RuboCop::Sorbet::Plugin"
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
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.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
- Peter Zhu
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2025-
|
13
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -98,6 +98,9 @@ files:
|
|
98
98
|
- lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb
|
99
99
|
- lib/rubocop/cop/sorbet/signatures/empty_line_after_sig.rb
|
100
100
|
- lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb
|
101
|
+
- lib/rubocop/cop/sorbet/signatures/forbid_sig.rb
|
102
|
+
- lib/rubocop/cop/sorbet/signatures/forbid_sig_with_runtime.rb
|
103
|
+
- lib/rubocop/cop/sorbet/signatures/forbid_sig_without_runtime.rb
|
101
104
|
- lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb
|
102
105
|
- lib/rubocop/cop/sorbet/signatures/signature_build_order.rb
|
103
106
|
- lib/rubocop/cop/sorbet/signatures/void_checked_tests.rb
|
@@ -107,6 +110,7 @@ files:
|
|
107
110
|
- lib/rubocop/cop/sorbet_cops.rb
|
108
111
|
- lib/rubocop/sorbet.rb
|
109
112
|
- lib/rubocop/sorbet/inject.rb
|
113
|
+
- lib/rubocop/sorbet/plugin.rb
|
110
114
|
- lib/rubocop/sorbet/version.rb
|
111
115
|
- manual/cops.md
|
112
116
|
- manual/cops_sorbet.md
|
@@ -121,6 +125,7 @@ metadata:
|
|
121
125
|
allowed_push_host: https://rubygems.org
|
122
126
|
homepage_uri: https://github.com/shopify/rubocop-sorbet
|
123
127
|
source_code_uri: https://github.com/shopify/rubocop-sorbet
|
128
|
+
default_lint_roller_plugin: RuboCop::Sorbet::Plugin
|
124
129
|
rdoc_options: []
|
125
130
|
require_paths:
|
126
131
|
- lib
|
@@ -135,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
140
|
- !ruby/object:Gem::Version
|
136
141
|
version: '0'
|
137
142
|
requirements: []
|
138
|
-
rubygems_version: 3.6.
|
143
|
+
rubygems_version: 3.6.6
|
139
144
|
specification_version: 4
|
140
145
|
summary: Automatic Sorbet code style checking tool.
|
141
146
|
test_files: []
|