rubocop-sorbet 0.6.11 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3 -1
- data/.github/workflows/cla.yml +22 -0
- data/.github/workflows/stale.yml +24 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -5
- data/config/default.yml +17 -1
- data/dev.yml +1 -1
- data/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb +8 -4
- data/lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb +2 -1
- data/lib/rubocop/cop/sorbet/redundant_extend_t_sig.rb +50 -0
- data/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb +2 -2
- data/lib/rubocop/cop/sorbet/signatures/empty_line_after_sig.rb +57 -0
- data/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb +2 -0
- data/lib/rubocop/cop/sorbet/signatures/signature_cop.rb +5 -8
- data/lib/rubocop/cop/sorbet_cops.rb +2 -0
- data/lib/rubocop/sorbet/version.rb +1 -1
- data/manual/cops.md +2 -0
- data/manual/cops_sorbet.md +59 -8
- data/service.yml +0 -1
- metadata +6 -4
- data/.github/probots.yml +0 -3
- data/.github/stale.yml +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87c7e5f3cd38dc5528234c83895115c4f0fe10010c041c0c914f73cf92f289f4
|
4
|
+
data.tar.gz: f991837c8cce7938ae4f0043b2c10a98b9130bd01f0d2b95f62a967e03337fab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71581073a6caba33b050d643815d98fdeae36d17eedbbcab985b9b467c9ccde100f153c58970ac3fb06f03c7834170fab65276f499bcf5e398b8dfdcde0ae5f7
|
7
|
+
data.tar.gz: 66ab517902652d5921967544c7c81d89b758886d9c893b2ed60d0e32a4826fc8391c6e91c6c0701e17c916a0a6535390fead92f740cc367e34530865cc4e4122
|
data/.github/workflows/ci.yml
CHANGED
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
|
-
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ]
|
14
|
+
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', '3.2' ]
|
15
15
|
name: Test Ruby ${{ matrix.ruby }}
|
16
16
|
steps:
|
17
17
|
- uses: actions/checkout@v2
|
@@ -22,5 +22,7 @@ jobs:
|
|
22
22
|
bundler-cache: true
|
23
23
|
- name: Lint Ruby files
|
24
24
|
run: bin/rubocop
|
25
|
+
- name: Verify documentation is up to date
|
26
|
+
run: bundle exec rake generate_cops_documentation
|
25
27
|
- name: Run tests
|
26
28
|
run: bin/rspec
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Contributor License Agreement (CLA)
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request_target:
|
5
|
+
types: [opened, synchronize, reopened]
|
6
|
+
issue_comment:
|
7
|
+
types: [created]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
cla:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
if: |
|
13
|
+
(github.event.issue.pull_request
|
14
|
+
&& !github.event.issue.pull_request.merged_at
|
15
|
+
&& contains(github.event.comment.body, 'signed')
|
16
|
+
)
|
17
|
+
|| (github.event.pull_request && !github.event.pull_request.merged)
|
18
|
+
steps:
|
19
|
+
- uses: Shopify/shopify-cla-action@v1
|
20
|
+
with:
|
21
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
22
|
+
cla-token: ${{ secrets.CLA_TOKEN }}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: "Close stale PRs"
|
2
|
+
|
3
|
+
permissions:
|
4
|
+
pull-requests: write
|
5
|
+
issues: write
|
6
|
+
|
7
|
+
on:
|
8
|
+
schedule:
|
9
|
+
- cron: "55 1 * * *"
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
stale:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- uses: actions/stale@v5
|
16
|
+
with:
|
17
|
+
stale-pr-message: >
|
18
|
+
This PR has been automatically marked as stale because it has not had
|
19
|
+
recent activity. It will be closed if no further activity occurs. Thank you
|
20
|
+
for your contributions.
|
21
|
+
days-before-stale: 30
|
22
|
+
days-before-issue-stale: -1
|
23
|
+
days-before-close: 7
|
24
|
+
exempt-pr-labels: pinned,security
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -22,15 +22,15 @@ task :new_cop, [:cop] do |_task, args|
|
|
22
22
|
exit!
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
github_user = "Shopify" if github_user.empty?
|
27
|
-
|
28
|
-
generator = RuboCop::Cop::Generator.new(cop_name, github_user)
|
25
|
+
generator = RuboCop::Cop::Generator.new(cop_name)
|
29
26
|
|
30
27
|
generator.write_source
|
31
28
|
generator.write_spec
|
32
29
|
generator.inject_require(root_file_path: "lib/rubocop/cop/sorbet_cops.rb")
|
33
30
|
generator.inject_config(config_file_path: "config/default.yml")
|
34
31
|
|
35
|
-
|
32
|
+
# We don't use Rubocop's changelog automation workflow
|
33
|
+
todo_without_changelog_instruction = generator.todo
|
34
|
+
.sub(/$\s+4\. Run.*changelog.*for your new cop\.$/m, "")
|
35
|
+
puts todo_without_changelog_instruction
|
36
36
|
end
|
data/config/default.yml
CHANGED
@@ -25,6 +25,11 @@ Sorbet/CheckedTrueInSignature:
|
|
25
25
|
Enabled: true
|
26
26
|
VersionAdded: 0.2.0
|
27
27
|
|
28
|
+
Sorbet/EmptyLineAfterSig:
|
29
|
+
Description: 'Ensures that there are no blank lines after signatures'
|
30
|
+
Enabled: true
|
31
|
+
VersionAdded: 0.7.0
|
32
|
+
|
28
33
|
Sorbet/ConstantsFromStrings:
|
29
34
|
Description: >-
|
30
35
|
Forbids constant access through meta-programming.
|
@@ -42,7 +47,7 @@ Sorbet/EnforceSigilOrder:
|
|
42
47
|
Sorbet/EnforceSingleSigil:
|
43
48
|
Description: 'Ensures that there is only one Sorbet sigil in a file.'
|
44
49
|
Enabled: true
|
45
|
-
VersionAdded:
|
50
|
+
VersionAdded: 0.7.0
|
46
51
|
|
47
52
|
Sorbet/EnforceSignatures:
|
48
53
|
Description: 'Ensures all methods have a valid signature.'
|
@@ -73,6 +78,7 @@ Sorbet/ForbidRBIOutsideOfAllowedPaths:
|
|
73
78
|
Enabled: true
|
74
79
|
VersionAdded: 0.6.1
|
75
80
|
AllowedPaths:
|
81
|
+
- "rbi/**"
|
76
82
|
- "sorbet/rbi/**"
|
77
83
|
Include:
|
78
84
|
- "**/*.rbi"
|
@@ -150,6 +156,16 @@ Sorbet/OneAncestorPerLine:
|
|
150
156
|
Enabled: false
|
151
157
|
VersionAdded: '0.6.0'
|
152
158
|
|
159
|
+
Sorbet/RedundantExtendTSig:
|
160
|
+
Description: >-
|
161
|
+
Forbid the usage of redundant `extend T::Sig`.
|
162
|
+
|
163
|
+
Only for use in applications that monkey patch `Module.include(T::Sig)` directly,
|
164
|
+
where it is useful to reduce noise.
|
165
|
+
Enabled: false
|
166
|
+
Safe: false
|
167
|
+
VersionAdded: 0.7.0
|
168
|
+
|
153
169
|
Sorbet/SignatureBuildOrder:
|
154
170
|
Description: >-
|
155
171
|
Enforces the order of parts in a signature.
|
data/dev.yml
CHANGED
@@ -7,18 +7,18 @@ module RuboCop
|
|
7
7
|
module Cop
|
8
8
|
module Sorbet
|
9
9
|
# This cop disallows use of `T.untyped` or `T.nilable(T.untyped)`
|
10
|
-
# as a prop type for `T::Struct`.
|
10
|
+
# as a prop type for `T::Struct` or `T::ImmutableStruct`.
|
11
11
|
#
|
12
12
|
# @example
|
13
13
|
#
|
14
14
|
# # bad
|
15
|
-
# class SomeClass
|
15
|
+
# class SomeClass < T::Struct
|
16
16
|
# const :foo, T.untyped
|
17
17
|
# prop :bar, T.nilable(T.untyped)
|
18
18
|
# end
|
19
19
|
#
|
20
20
|
# # good
|
21
|
-
# class SomeClass
|
21
|
+
# class SomeClass < T::Struct
|
22
22
|
# const :foo, Integer
|
23
23
|
# prop :bar, T.nilable(String)
|
24
24
|
# end
|
@@ -29,6 +29,10 @@ module RuboCop
|
|
29
29
|
(const (const nil? :T) :Struct)
|
30
30
|
PATTERN
|
31
31
|
|
32
|
+
def_node_matcher :t_immutable_struct, <<~PATTERN
|
33
|
+
(const (const nil? :T) :ImmutableStruct)
|
34
|
+
PATTERN
|
35
|
+
|
32
36
|
def_node_matcher :t_untyped, <<~PATTERN
|
33
37
|
(send (const nil? :T) :untyped)
|
34
38
|
PATTERN
|
@@ -38,7 +42,7 @@ module RuboCop
|
|
38
42
|
PATTERN
|
39
43
|
|
40
44
|
def_node_matcher :subclass_of_t_struct?, <<~PATTERN
|
41
|
-
(class (const ...) #t_struct ...)
|
45
|
+
(class (const ...) {#t_struct #t_immutable_struct} ...)
|
42
46
|
PATTERN
|
43
47
|
|
44
48
|
def_node_search :untyped_props, <<~PATTERN
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
9
9
|
#
|
10
10
|
# Options:
|
11
11
|
#
|
12
|
-
# * `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["sorbet/rbi/**"])
|
12
|
+
# * `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["rbi/**", "sorbet/rbi/**"])
|
13
13
|
#
|
14
14
|
# @example
|
15
15
|
# # bad
|
@@ -17,6 +17,7 @@ module RuboCop
|
|
17
17
|
# # other_file.rbi
|
18
18
|
#
|
19
19
|
# # good
|
20
|
+
# # rbi/external_interface.rbi
|
20
21
|
# # sorbet/rbi/some_file.rbi
|
21
22
|
# # sorbet/rbi/any/path/for/file.rbi
|
22
23
|
class ForbidRBIOutsideOfAllowedPaths < RuboCop::Cop::Cop
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sorbet
|
6
|
+
# Forbids the use of redundant `extend T::Sig`. Only for use in
|
7
|
+
# applications that monkey patch `Module.include(T::Sig)` globally,
|
8
|
+
# which would make it redundant.
|
9
|
+
#
|
10
|
+
# @safety
|
11
|
+
# This cop should not be enabled in applications that have not monkey
|
12
|
+
# patched `Module`.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# # bad
|
16
|
+
# class Example
|
17
|
+
# extend T::Sig
|
18
|
+
# sig { void }
|
19
|
+
# def no_op; end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# # good
|
23
|
+
# class Example
|
24
|
+
# sig { void }
|
25
|
+
# def no_op; end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
class RedundantExtendTSig < RuboCop::Cop::Cop
|
29
|
+
MSG = "Do not redundantly `extend T::Sig` when it is already included in all modules."
|
30
|
+
RESTRICT_ON_SEND = [:extend].freeze
|
31
|
+
|
32
|
+
def_node_matcher :extend_t_sig?, <<~PATTERN
|
33
|
+
(send _ :extend (const (const {nil? | cbase} :T) :Sig))
|
34
|
+
PATTERN
|
35
|
+
|
36
|
+
def on_send(node)
|
37
|
+
return unless extend_t_sig?(node)
|
38
|
+
|
39
|
+
add_offense(node)
|
40
|
+
end
|
41
|
+
|
42
|
+
def autocorrect(node)
|
43
|
+
lambda do |corrector|
|
44
|
+
corrector.remove(node)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
module Sorbet
|
8
8
|
# This cop checks that the Sorbet sigil comes as the first magic comment in the file.
|
9
9
|
#
|
10
|
-
# The expected order for magic comments is:
|
10
|
+
# The expected order for magic comments is: (en)?coding, typed, warn_indent then frozen_string_literal.
|
11
11
|
#
|
12
12
|
# For example, the following bad ordering:
|
13
13
|
#
|
@@ -25,7 +25,7 @@ module RuboCop
|
|
25
25
|
# class Foo; end
|
26
26
|
# ```
|
27
27
|
#
|
28
|
-
# Only `
|
28
|
+
# Only `(en)?coding`, `typed`, `warn_indent` and `frozen_string_literal` magic comments are considered,
|
29
29
|
# other comments or magic comments are left in the same place.
|
30
30
|
class EnforceSigilOrder < ValidSigil
|
31
31
|
include RangeHelp
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "signature_cop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Sorbet
|
8
|
+
# This cop checks for blank lines after signatures.
|
9
|
+
#
|
10
|
+
# It also suggests an autocorrect
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
#
|
14
|
+
# # bad
|
15
|
+
# sig { void }
|
16
|
+
#
|
17
|
+
# def foo; end
|
18
|
+
#
|
19
|
+
# # good
|
20
|
+
# sig { void }
|
21
|
+
# def foo; end
|
22
|
+
#
|
23
|
+
class EmptyLineAfterSig < SignatureCop
|
24
|
+
include RangeHelp
|
25
|
+
|
26
|
+
def on_signature(node)
|
27
|
+
if (next_method(node).line - node.last_line) > 1
|
28
|
+
location = source_range(processed_source.buffer, next_method(node).line - 1, 0)
|
29
|
+
add_offense(node, location: location, message: "Extra empty line or comment detected")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def autocorrect(node)
|
34
|
+
-> (corrector) do
|
35
|
+
offending_range = node.source_range.with(
|
36
|
+
begin_pos: node.source_range.end_pos + 1,
|
37
|
+
end_pos: processed_source.buffer.line_range(next_method(node).line).begin_pos
|
38
|
+
)
|
39
|
+
corrector.remove(offending_range)
|
40
|
+
clean_range = offending_range.source.split("\n").reject(&:empty?).join("\n")
|
41
|
+
offending_line = processed_source.buffer.line_range(node.source_range.first_line)
|
42
|
+
corrector.insert_before(offending_line, "#{clean_range}\n") unless clean_range.empty?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def next_method(node)
|
49
|
+
processed_source.tokens.find do |t|
|
50
|
+
t.line >= node.last_line &&
|
51
|
+
(t.type == :kDEF || t.text.start_with?("attr_"))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -12,7 +12,11 @@ module RuboCop
|
|
12
12
|
@registry = Cop.registry # So we can properly subclass this cop
|
13
13
|
|
14
14
|
def_node_matcher(:signature?, <<~PATTERN)
|
15
|
-
(block (send
|
15
|
+
(block (send
|
16
|
+
{nil? #with_runtime? #without_runtime?}
|
17
|
+
:sig
|
18
|
+
(sym :final)?
|
19
|
+
) (args) ...)
|
16
20
|
PATTERN
|
17
21
|
|
18
22
|
def_node_matcher(:with_runtime?, <<~PATTERN)
|
@@ -23,13 +27,6 @@ module RuboCop
|
|
23
27
|
(const (const (const nil? :T) :Sig) :WithoutRuntime)
|
24
28
|
PATTERN
|
25
29
|
|
26
|
-
def allowed_recv(recv)
|
27
|
-
return true unless recv
|
28
|
-
return true if with_runtime?(recv)
|
29
|
-
return true if without_runtime?(recv)
|
30
|
-
false
|
31
|
-
end
|
32
|
-
|
33
30
|
def on_block(node)
|
34
31
|
on_signature(node) if signature?(node)
|
35
32
|
end
|
@@ -8,6 +8,7 @@ require_relative "sorbet/one_ancestor_per_line"
|
|
8
8
|
require_relative "sorbet/callback_conditionals_binding"
|
9
9
|
require_relative "sorbet/forbid_t_unsafe"
|
10
10
|
require_relative "sorbet/forbid_t_untyped"
|
11
|
+
require_relative "sorbet/redundant_extend_t_sig"
|
11
12
|
require_relative "sorbet/type_alias_name"
|
12
13
|
|
13
14
|
require_relative "sorbet/rbi/forbid_extend_t_sig_helpers_in_shims"
|
@@ -19,6 +20,7 @@ require_relative "sorbet/signatures/checked_true_in_signature"
|
|
19
20
|
require_relative "sorbet/signatures/keyword_argument_ordering"
|
20
21
|
require_relative "sorbet/signatures/signature_build_order"
|
21
22
|
require_relative "sorbet/signatures/enforce_signatures"
|
23
|
+
require_relative "sorbet/signatures/empty_line_after_sig"
|
22
24
|
|
23
25
|
require_relative "sorbet/sigils/valid_sigil"
|
24
26
|
require_relative "sorbet/sigils/has_sigil"
|
data/manual/cops.md
CHANGED
@@ -10,6 +10,7 @@ In the following section you find all available cops:
|
|
10
10
|
* [Sorbet/CallbackConditionalsBinding](cops_sorbet.md#sorbetcallbackconditionalsbinding)
|
11
11
|
* [Sorbet/CheckedTrueInSignature](cops_sorbet.md#sorbetcheckedtrueinsignature)
|
12
12
|
* [Sorbet/ConstantsFromStrings](cops_sorbet.md#sorbetconstantsfromstrings)
|
13
|
+
* [Sorbet/EmptyLineAfterSig](cops_sorbet.md#sorbetemptylineaftersig)
|
13
14
|
* [Sorbet/EnforceSigilOrder](cops_sorbet.md#sorbetenforcesigilorder)
|
14
15
|
* [Sorbet/EnforceSignatures](cops_sorbet.md#sorbetenforcesignatures)
|
15
16
|
* [Sorbet/EnforceSingleSigil](cops_sorbet.md#sorbetenforcesinglesigil)
|
@@ -25,6 +26,7 @@ In the following section you find all available cops:
|
|
25
26
|
* [Sorbet/IgnoreSigil](cops_sorbet.md#sorbetignoresigil)
|
26
27
|
* [Sorbet/KeywordArgumentOrdering](cops_sorbet.md#sorbetkeywordargumentordering)
|
27
28
|
* [Sorbet/OneAncestorPerLine](cops_sorbet.md#sorbetoneancestorperline)
|
29
|
+
* [Sorbet/RedundantExtendTSig](cops_sorbet.md#sorbetredundantextendtsig)
|
28
30
|
* [Sorbet/SignatureBuildOrder](cops_sorbet.md#sorbetsignaturebuildorder)
|
29
31
|
* [Sorbet/SignatureCop](cops_sorbet.md#sorbetsignaturecop)
|
30
32
|
* [Sorbet/SingleLineRbiClassModuleDefinitions](cops_sorbet.md#sorbetsinglelinerbiclassmoduledefinitions)
|
data/manual/cops_sorbet.md
CHANGED
@@ -138,6 +138,29 @@ end
|
|
138
138
|
{ "User" => User }.fetch(class_name)
|
139
139
|
```
|
140
140
|
|
141
|
+
## Sorbet/EmptyLineAfterSig
|
142
|
+
|
143
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
144
|
+
--- | --- | --- | --- | ---
|
145
|
+
Enabled | Yes | Yes | 0.7.0 | -
|
146
|
+
|
147
|
+
This cop checks for blank lines after signatures.
|
148
|
+
|
149
|
+
It also suggests an autocorrect
|
150
|
+
|
151
|
+
### Examples
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
# bad
|
155
|
+
sig { void }
|
156
|
+
|
157
|
+
def foo; end
|
158
|
+
|
159
|
+
# good
|
160
|
+
sig { void }
|
161
|
+
def foo; end
|
162
|
+
```
|
163
|
+
|
141
164
|
## Sorbet/EnforceSigilOrder
|
142
165
|
|
143
166
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
@@ -146,7 +169,7 @@ Enabled | Yes | Yes | 0.3.4 | -
|
|
146
169
|
|
147
170
|
This cop checks that the Sorbet sigil comes as the first magic comment in the file.
|
148
171
|
|
149
|
-
The expected order for magic comments is:
|
172
|
+
The expected order for magic comments is: (en)?coding, typed, warn_indent then frozen_string_literal.
|
150
173
|
|
151
174
|
For example, the following bad ordering:
|
152
175
|
|
@@ -164,7 +187,7 @@ Will be corrected as:
|
|
164
187
|
class Foo; end
|
165
188
|
```
|
166
189
|
|
167
|
-
Only `
|
190
|
+
Only `(en)?coding`, `typed`, `warn_indent` and `frozen_string_literal` magic comments are considered,
|
168
191
|
other comments or magic comments are left in the same place.
|
169
192
|
|
170
193
|
## Sorbet/EnforceSignatures
|
@@ -197,7 +220,7 @@ You can configure the placeholders used by changing the following options:
|
|
197
220
|
|
198
221
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
199
222
|
--- | --- | --- | --- | ---
|
200
|
-
Enabled | Yes | Yes |
|
223
|
+
Enabled | Yes | Yes | 0.7.0 | -
|
201
224
|
|
202
225
|
This cop checks that there is only one Sorbet sigil in a given file
|
203
226
|
|
@@ -288,7 +311,7 @@ This cop makes sure that RBI files are always located under the defined allowed
|
|
288
311
|
|
289
312
|
Options:
|
290
313
|
|
291
|
-
* `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["sorbet/rbi/**"])
|
314
|
+
* `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["rbi/**", "sorbet/rbi/**"])
|
292
315
|
|
293
316
|
### Examples
|
294
317
|
|
@@ -298,6 +321,7 @@ Options:
|
|
298
321
|
# other_file.rbi
|
299
322
|
|
300
323
|
# good
|
324
|
+
# rbi/external_interface.rbi
|
301
325
|
# sorbet/rbi/some_file.rbi
|
302
326
|
# sorbet/rbi/any/path/for/file.rbi
|
303
327
|
```
|
@@ -306,7 +330,7 @@ Options:
|
|
306
330
|
|
307
331
|
Name | Default value | Configurable values
|
308
332
|
--- | --- | ---
|
309
|
-
AllowedPaths | `sorbet/rbi/**` | Array
|
333
|
+
AllowedPaths | `rbi/**`, `sorbet/rbi/**` | Array
|
310
334
|
Include | `**/*.rbi` | Array
|
311
335
|
|
312
336
|
## Sorbet/ForbidSuperclassConstLiteral
|
@@ -368,19 +392,19 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChan
|
|
368
392
|
Enabled | Yes | No | 0.4.0 | -
|
369
393
|
|
370
394
|
This cop disallows use of `T.untyped` or `T.nilable(T.untyped)`
|
371
|
-
as a prop type for `T::Struct`.
|
395
|
+
as a prop type for `T::Struct` or `T::ImmutableStruct`.
|
372
396
|
|
373
397
|
### Examples
|
374
398
|
|
375
399
|
```ruby
|
376
400
|
# bad
|
377
|
-
class SomeClass
|
401
|
+
class SomeClass < T::Struct
|
378
402
|
const :foo, T.untyped
|
379
403
|
prop :bar, T.nilable(T.untyped)
|
380
404
|
end
|
381
405
|
|
382
406
|
# good
|
383
|
-
class SomeClass
|
407
|
+
class SomeClass < T::Struct
|
384
408
|
const :foo, Integer
|
385
409
|
prop :bar, T.nilable(String)
|
386
410
|
end
|
@@ -473,6 +497,33 @@ module SomeModule
|
|
473
497
|
end
|
474
498
|
```
|
475
499
|
|
500
|
+
## Sorbet/RedundantExtendTSig
|
501
|
+
|
502
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
503
|
+
--- | --- | --- | --- | ---
|
504
|
+
Disabled | No | Yes | 0.7.0 | -
|
505
|
+
|
506
|
+
Forbids the use of redundant `extend T::Sig`. Only for use in
|
507
|
+
applications that monkey patch `Module.include(T::Sig)` globally,
|
508
|
+
which would make it redundant.
|
509
|
+
|
510
|
+
### Examples
|
511
|
+
|
512
|
+
```ruby
|
513
|
+
# bad
|
514
|
+
class Example
|
515
|
+
extend T::Sig
|
516
|
+
sig { void }
|
517
|
+
def no_op; end
|
518
|
+
end
|
519
|
+
|
520
|
+
# good
|
521
|
+
class Example
|
522
|
+
sig { void }
|
523
|
+
def no_op; end
|
524
|
+
end
|
525
|
+
```
|
526
|
+
|
476
527
|
## Sorbet/SignatureBuildOrder
|
477
528
|
|
478
529
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
data/service.yml
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
classification: library
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -63,10 +63,10 @@ extensions: []
|
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
65
|
- ".github/CODEOWNERS"
|
66
|
-
- ".github/probots.yml"
|
67
66
|
- ".github/release.yml"
|
68
|
-
- ".github/stale.yml"
|
69
67
|
- ".github/workflows/ci.yml"
|
68
|
+
- ".github/workflows/cla.yml"
|
69
|
+
- ".github/workflows/stale.yml"
|
70
70
|
- ".gitignore"
|
71
71
|
- ".rspec"
|
72
72
|
- ".rubocop.yml"
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb
|
99
99
|
- lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb
|
100
100
|
- lib/rubocop/cop/sorbet/rbi/single_line_rbi_class_module_definitions.rb
|
101
|
+
- lib/rubocop/cop/sorbet/redundant_extend_t_sig.rb
|
101
102
|
- lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb
|
102
103
|
- lib/rubocop/cop/sorbet/sigils/enforce_single_sigil.rb
|
103
104
|
- lib/rubocop/cop/sorbet/sigils/false_sigil.rb
|
@@ -109,6 +110,7 @@ files:
|
|
109
110
|
- lib/rubocop/cop/sorbet/sigils/valid_sigil.rb
|
110
111
|
- lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb
|
111
112
|
- lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb
|
113
|
+
- lib/rubocop/cop/sorbet/signatures/empty_line_after_sig.rb
|
112
114
|
- lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb
|
113
115
|
- lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb
|
114
116
|
- lib/rubocop/cop/sorbet/signatures/signature_build_order.rb
|
data/.github/probots.yml
DELETED
data/.github/stale.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# Number of days of inactivity before an issue becomes stale
|
2
|
-
daysUntilStale: 30
|
3
|
-
# Number of days of inactivity before a stale issue is closed
|
4
|
-
daysUntilClose: 7
|
5
|
-
# Issues with these labels will never be considered stale
|
6
|
-
exemptLabels:
|
7
|
-
- pinned
|
8
|
-
- security
|
9
|
-
# Label to use when marking an issue as stale
|
10
|
-
staleLabel: stale
|
11
|
-
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
|
-
markComment: >
|
13
|
-
This PR has been automatically marked as stale because it has not had
|
14
|
-
recent activity. It will be closed if no further activity occurs. Thank you
|
15
|
-
for your contributions.
|
16
|
-
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
-
closeComment: false
|
18
|
-
#
|
19
|
-
only: pulls
|
20
|
-
#
|