rubocop-sorbet 0.6.1 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/release.yml +23 -0
- data/.github/workflows/ci.yml +26 -0
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +25 -41
- data/README.md +24 -4
- data/Rakefile +12 -16
- data/bin/console +3 -3
- data/bin/rspec +6 -6
- data/bin/rubocop +29 -0
- data/config/default.yml +73 -10
- data/config/rbi.yml +265 -0
- data/dev.yml +1 -1
- data/lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb +4 -4
- data/lib/rubocop/cop/sorbet/callback_conditionals_binding.rb +142 -0
- data/lib/rubocop/cop/sorbet/constants_from_strings.rb +1 -1
- data/lib/rubocop/cop/sorbet/forbid_include_const_literal.rb +11 -2
- data/lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb +2 -2
- data/lib/rubocop/cop/sorbet/forbid_t_unsafe.rb +26 -0
- data/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb +2 -2
- data/lib/rubocop/cop/sorbet/one_ancestor_per_line.rb +2 -2
- data/lib/rubocop/cop/sorbet/{forbid_extend_t_sig_helpers_in_shims.rb → rbi/forbid_extend_t_sig_helpers_in_shims.rb} +1 -1
- data/lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb +65 -0
- data/lib/rubocop/cop/sorbet/{single_line_rbi_class_module_definitions.rb → rbi/single_line_rbi_class_module_definitions.rb} +1 -1
- data/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb +6 -6
- data/lib/rubocop/cop/sorbet/sigils/enforce_single_sigil.rb +63 -0
- data/lib/rubocop/cop/sorbet/sigils/false_sigil.rb +3 -3
- data/lib/rubocop/cop/sorbet/sigils/has_sigil.rb +2 -2
- data/lib/rubocop/cop/sorbet/sigils/ignore_sigil.rb +3 -3
- data/lib/rubocop/cop/sorbet/sigils/strict_sigil.rb +3 -3
- data/lib/rubocop/cop/sorbet/sigils/strong_sigil.rb +3 -3
- data/lib/rubocop/cop/sorbet/sigils/true_sigil.rb +3 -3
- data/lib/rubocop/cop/sorbet/sigils/valid_sigil.rb +10 -8
- data/lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb +3 -3
- data/lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb +6 -6
- data/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb +13 -13
- data/lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb +3 -3
- data/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb +6 -6
- data/lib/rubocop/cop/sorbet/signatures/signature_cop.rb +17 -2
- data/lib/rubocop/cop/sorbet_cops.rb +26 -22
- data/lib/rubocop/sorbet/version.rb +1 -1
- data/lib/rubocop/sorbet.rb +1 -1
- data/lib/rubocop-sorbet.rb +5 -5
- data/manual/cops.md +4 -1
- data/manual/cops_sorbet.md +167 -24
- data/rubocop-sorbet.gemspec +2 -2
- data/service.yml +0 -5
- data/tasks/cops_documentation.rake +60 -62
- metadata +19 -14
- data/.shopify-build/VERSION +0 -1
- data/.shopify-build/rubocop-sorbet.yml +0 -16
- data/lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb +0 -70
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sorbet
|
6
|
+
# This cop checks that there is only one Sorbet sigil in a given file
|
7
|
+
#
|
8
|
+
# For example, the following class with two sigils
|
9
|
+
#
|
10
|
+
# ```ruby
|
11
|
+
# # typed: true
|
12
|
+
# # typed: true
|
13
|
+
# # frozen_string_literal: true
|
14
|
+
# class Foo; end
|
15
|
+
# ```
|
16
|
+
#
|
17
|
+
# Will be corrected as:
|
18
|
+
#
|
19
|
+
# ```ruby
|
20
|
+
# # typed: true
|
21
|
+
# # frozen_string_literal: true
|
22
|
+
# class Foo; end
|
23
|
+
# ```
|
24
|
+
#
|
25
|
+
# Other comments or magic comments are left in place.
|
26
|
+
class EnforceSingleSigil < ValidSigil
|
27
|
+
include RangeHelp
|
28
|
+
|
29
|
+
def investigate(processed_source)
|
30
|
+
return if processed_source.tokens.empty?
|
31
|
+
sigils = extract_all_sigils(processed_source)
|
32
|
+
return unless sigils.size > 1
|
33
|
+
|
34
|
+
sigils[1..sigils.size].each do |token|
|
35
|
+
add_offense(token, location: token.pos, message: "Files must only contain one sigil")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def autocorrect(_node)
|
40
|
+
-> (corrector) do
|
41
|
+
sigils = extract_all_sigils(processed_source)
|
42
|
+
return unless sigils.size > 1
|
43
|
+
|
44
|
+
# The first sigil encountered represents the "real" strictness so remove any below
|
45
|
+
sigils[1..sigils.size].each do |token|
|
46
|
+
corrector.remove(
|
47
|
+
source_range(processed_source.buffer, token.line, (0..token.pos.last_column))
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def extract_all_sigils(processed_source)
|
56
|
+
processed_source.tokens
|
57
|
+
.take_while { |token| token.type == :tCOMMENT }
|
58
|
+
.find_all { |token| SIGIL_REGEX.match?(token.text) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "has_sigil"
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
9
9
|
# This cop makes the Sorbet `false` sigil mandatory in all files.
|
10
10
|
class FalseSigil < HasSigil
|
11
11
|
def minimum_strictness
|
12
|
-
|
12
|
+
"false"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "has_sigil"
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
9
9
|
# This cop makes the Sorbet `ignore` sigil mandatory in all files.
|
10
10
|
class IgnoreSigil < HasSigil
|
11
11
|
def minimum_strictness
|
12
|
-
|
12
|
+
"ignore"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "has_sigil"
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
9
9
|
# This cop makes the Sorbet `strict` sigil mandatory in all files.
|
10
10
|
class StrictSigil < HasSigil
|
11
11
|
def minimum_strictness
|
12
|
-
|
12
|
+
"strict"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "has_sigil"
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
9
9
|
# This cop makes the Sorbet `strong` sigil mandatory in all files.
|
10
10
|
class StrongSigil < HasSigil
|
11
11
|
def minimum_strictness
|
12
|
-
|
12
|
+
"strong"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "has_sigil"
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
9
9
|
# This cop makes the Sorbet `true` sigil mandatory in all files.
|
10
10
|
class TrueSigil < HasSigil
|
11
11
|
def minimum_strictness
|
12
|
-
|
12
|
+
"true"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rubocop"
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
@@ -48,7 +48,7 @@ module RuboCop
|
|
48
48
|
|
49
49
|
protected
|
50
50
|
|
51
|
-
STRICTNESS_LEVELS =
|
51
|
+
STRICTNESS_LEVELS = ["ignore", "false", "true", "strict", "strong"]
|
52
52
|
SIGIL_REGEX = /#\s+typed:(?:\s+([\w]+))?/
|
53
53
|
|
54
54
|
# extraction
|
@@ -74,7 +74,7 @@ module RuboCop
|
|
74
74
|
add_offense(
|
75
75
|
token,
|
76
76
|
location: token.pos,
|
77
|
-
message:
|
77
|
+
message: "No Sorbet sigil found in file. " \
|
78
78
|
"Try a `typed: #{strictness}` to start (you can also use `rubocop -a` to automatically add this)."
|
79
79
|
)
|
80
80
|
end
|
@@ -87,7 +87,7 @@ module RuboCop
|
|
87
87
|
return suggested_strictness unless minimum_strictness
|
88
88
|
|
89
89
|
# special case: if you're using Sorbet/IgnoreSigil without config, we should recommend `ignore`
|
90
|
-
return "ignore" if minimum_strictness == "ignore" && cop_config[
|
90
|
+
return "ignore" if minimum_strictness == "ignore" && cop_config["SuggestedStrictness"].nil?
|
91
91
|
|
92
92
|
# if a minimum strictness is set (eg. you're using Sorbet/FalseSigil)
|
93
93
|
# we want to compare the minimum strictness and suggested strictness. this is because
|
@@ -106,7 +106,7 @@ module RuboCop
|
|
106
106
|
add_offense(
|
107
107
|
sigil,
|
108
108
|
location: sigil.pos,
|
109
|
-
message:
|
109
|
+
message: "Sorbet sigil should not be empty."
|
110
110
|
)
|
111
111
|
false
|
112
112
|
end
|
@@ -142,17 +142,19 @@ module RuboCop
|
|
142
142
|
|
143
143
|
# Default is `false`
|
144
144
|
def require_sigil_on_all_files?
|
145
|
-
!!cop_config[
|
145
|
+
!!cop_config["RequireSigilOnAllFiles"]
|
146
146
|
end
|
147
147
|
|
148
148
|
# Default is `'false'`
|
149
149
|
def suggested_strictness
|
150
|
-
|
150
|
+
config = cop_config["SuggestedStrictness"].to_s
|
151
|
+
STRICTNESS_LEVELS.include?(config) ? config : "false"
|
151
152
|
end
|
152
153
|
|
153
154
|
# Default is `nil`
|
154
155
|
def minimum_strictness
|
155
|
-
|
156
|
+
config = cop_config["MinimumStrictness"].to_s
|
157
|
+
config if STRICTNESS_LEVELS.include?(config)
|
156
158
|
end
|
157
159
|
end
|
158
160
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rubocop"
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
@@ -49,8 +49,8 @@ module RuboCop
|
|
49
49
|
return unless allow_incompatible_override?(node)
|
50
50
|
add_offense(
|
51
51
|
node.children[2],
|
52
|
-
message:
|
53
|
-
|
52
|
+
message: "Usage of `allow_incompatible` suggests a violation of the Liskov Substitution Principle. "\
|
53
|
+
"Instead, strive to write interfaces which respect subtyping principles and remove `allow_incompatible`",
|
54
54
|
)
|
55
55
|
end
|
56
56
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "signature_cop"
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
@@ -27,10 +27,10 @@ module RuboCop
|
|
27
27
|
PATTERN
|
28
28
|
|
29
29
|
MESSAGE =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
"Using `checked(true)` in a method signature definition is not allowed. " \
|
31
|
+
"`checked(true)` is the default behavior for modules/classes with runtime checks enabled. " \
|
32
|
+
"To enable typechecking at runtime for this module, regardless of global settings, " \
|
33
|
+
"`include(WaffleCone::RuntimeChecks)` to this module and set other methods to `checked(false)`."
|
34
34
|
private_constant(:MESSAGE)
|
35
35
|
|
36
36
|
def on_signature(node)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require "stringio"
|
5
|
+
require_relative "signature_cop"
|
6
6
|
|
7
7
|
module RuboCop
|
8
8
|
module Cop
|
@@ -48,8 +48,8 @@ module RuboCop
|
|
48
48
|
check_node(node) if accessor?(node)
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
@last_sig_for_scope[scope(node)] = node
|
51
|
+
def on_signature(node)
|
52
|
+
@last_sig_for_scope[scope(node)] = node
|
53
53
|
end
|
54
54
|
|
55
55
|
def autocorrect(node)
|
@@ -64,7 +64,7 @@ module RuboCop
|
|
64
64
|
method = node.children[1]
|
65
65
|
symbol = node.children[2]
|
66
66
|
suggest.params << symbol.value if symbol && (method == :attr_writer || method == :attr_accessor)
|
67
|
-
suggest.returns =
|
67
|
+
suggest.returns = "void" if method == :attr_writer
|
68
68
|
end
|
69
69
|
|
70
70
|
corrector.insert_before(node.loc.expression, suggest.to_autocorrect)
|
@@ -91,11 +91,11 @@ module RuboCop
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def param_type_placeholder
|
94
|
-
cop_config[
|
94
|
+
cop_config["ParameterTypePlaceholder"] || "T.untyped"
|
95
95
|
end
|
96
96
|
|
97
97
|
def return_type_placeholder
|
98
|
-
cop_config[
|
98
|
+
cop_config["ReturnTypePlaceholder"] || "T.untyped"
|
99
99
|
end
|
100
100
|
|
101
101
|
class SigSuggestion
|
@@ -111,11 +111,11 @@ module RuboCop
|
|
111
111
|
|
112
112
|
def to_autocorrect
|
113
113
|
out = StringIO.new
|
114
|
-
out <<
|
114
|
+
out << "sig { "
|
115
115
|
out << generate_params
|
116
116
|
out << generate_return
|
117
117
|
out << " }\n"
|
118
|
-
out <<
|
118
|
+
out << " " * @indent # preserve indent for the next line
|
119
119
|
out.string
|
120
120
|
end
|
121
121
|
|
@@ -124,17 +124,17 @@ module RuboCop
|
|
124
124
|
def generate_params
|
125
125
|
return if @params.empty?
|
126
126
|
out = StringIO.new
|
127
|
-
out <<
|
127
|
+
out << "params("
|
128
128
|
out << @params.map do |param|
|
129
129
|
"#{param}: #{@param_placeholder}"
|
130
130
|
end.join(", ")
|
131
|
-
out <<
|
131
|
+
out << ")."
|
132
132
|
out.string
|
133
133
|
end
|
134
134
|
|
135
135
|
def generate_return
|
136
136
|
return "returns(#{@return_placeholder})" if @returns.nil?
|
137
|
-
return @returns if @returns ==
|
137
|
+
return @returns if @returns == "void"
|
138
138
|
"returns(#{@returns})"
|
139
139
|
end
|
140
140
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "signature_cop"
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
|
42
42
|
add_offense(
|
43
43
|
param,
|
44
|
-
message:
|
44
|
+
message: "Optional keyword arguments must be at the end of the parameter list."
|
45
45
|
)
|
46
46
|
end
|
47
47
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rubocop"
|
4
|
+
require_relative "signature_cop"
|
5
5
|
|
6
6
|
begin
|
7
|
-
require
|
7
|
+
require "unparser"
|
8
8
|
rescue LoadError
|
9
9
|
nil
|
10
10
|
end
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
28
28
|
].each_with_index.to_h.freeze
|
29
29
|
|
30
30
|
def_node_search(:root_call, <<~PATTERN)
|
31
|
-
(send nil? {#{ORDER.keys.map(&:inspect).join(
|
31
|
+
(send nil? {#{ORDER.keys.map(&:inspect).join(" ")}} ...)
|
32
32
|
PATTERN
|
33
33
|
|
34
34
|
def on_signature(node)
|
@@ -38,10 +38,10 @@ module RuboCop
|
|
38
38
|
expected_order = calls.sort_by { |call| ORDER[call] }
|
39
39
|
return if expected_order == calls
|
40
40
|
|
41
|
-
message = "Sig builders must be invoked in the following order: #{expected_order.join(
|
41
|
+
message = "Sig builders must be invoked in the following order: #{expected_order.join(", ")}."
|
42
42
|
|
43
43
|
unless can_autocorrect?
|
44
|
-
message +=
|
44
|
+
message += " For autocorrection, add the `unparser` gem to your project."
|
45
45
|
end
|
46
46
|
|
47
47
|
add_offense(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rubocop"
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
@@ -12,9 +12,24 @@ 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 #allowed_recv :sig) (args) ...)
|
16
16
|
PATTERN
|
17
17
|
|
18
|
+
def_node_matcher(:with_runtime?, <<~PATTERN)
|
19
|
+
(const (const nil? :T) :Sig)
|
20
|
+
PATTERN
|
21
|
+
|
22
|
+
def_node_matcher(:without_runtime?, <<~PATTERN)
|
23
|
+
(const (const (const nil? :T) :Sig) :WithoutRuntime)
|
24
|
+
PATTERN
|
25
|
+
|
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
|
+
|
18
33
|
def on_block(node)
|
19
34
|
on_signature(node) if signature?(node)
|
20
35
|
end
|
@@ -1,25 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
2
|
+
require_relative "sorbet/binding_constants_without_type_alias"
|
3
|
+
require_relative "sorbet/constants_from_strings"
|
4
|
+
require_relative "sorbet/forbid_superclass_const_literal"
|
5
|
+
require_relative "sorbet/forbid_include_const_literal"
|
6
|
+
require_relative "sorbet/forbid_untyped_struct_props"
|
7
|
+
require_relative "sorbet/one_ancestor_per_line"
|
8
|
+
require_relative "sorbet/callback_conditionals_binding"
|
9
|
+
require_relative "sorbet/forbid_t_unsafe"
|
10
10
|
|
11
|
-
require_relative
|
12
|
-
require_relative
|
13
|
-
require_relative
|
14
|
-
require_relative 'sorbet/signatures/parameters_ordering_in_signature'
|
15
|
-
require_relative 'sorbet/signatures/signature_build_order'
|
16
|
-
require_relative 'sorbet/signatures/enforce_signatures'
|
11
|
+
require_relative "sorbet/rbi/forbid_extend_t_sig_helpers_in_shims"
|
12
|
+
require_relative "sorbet/rbi/forbid_rbi_outside_of_allowed_paths"
|
13
|
+
require_relative "sorbet/rbi/single_line_rbi_class_module_definitions"
|
17
14
|
|
18
|
-
require_relative
|
19
|
-
require_relative
|
20
|
-
require_relative
|
21
|
-
require_relative
|
22
|
-
require_relative
|
23
|
-
|
24
|
-
require_relative
|
25
|
-
require_relative
|
15
|
+
require_relative "sorbet/signatures/allow_incompatible_override"
|
16
|
+
require_relative "sorbet/signatures/checked_true_in_signature"
|
17
|
+
require_relative "sorbet/signatures/keyword_argument_ordering"
|
18
|
+
require_relative "sorbet/signatures/signature_build_order"
|
19
|
+
require_relative "sorbet/signatures/enforce_signatures"
|
20
|
+
|
21
|
+
require_relative "sorbet/sigils/valid_sigil"
|
22
|
+
require_relative "sorbet/sigils/has_sigil"
|
23
|
+
require_relative "sorbet/sigils/ignore_sigil"
|
24
|
+
require_relative "sorbet/sigils/false_sigil"
|
25
|
+
require_relative "sorbet/sigils/true_sigil"
|
26
|
+
require_relative "sorbet/sigils/strict_sigil"
|
27
|
+
require_relative "sorbet/sigils/strong_sigil"
|
28
|
+
require_relative "sorbet/sigils/enforce_sigil_order"
|
29
|
+
require_relative "sorbet/sigils/enforce_single_sigil"
|
data/lib/rubocop/sorbet.rb
CHANGED
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
class Error < StandardError; end
|
8
8
|
|
9
9
|
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
10
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join(
|
10
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze
|
11
11
|
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
12
12
|
|
13
13
|
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
data/lib/rubocop-sorbet.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rubocop"
|
4
4
|
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
5
|
+
require_relative "rubocop/sorbet"
|
6
|
+
require_relative "rubocop/sorbet/version"
|
7
|
+
require_relative "rubocop/sorbet/inject"
|
8
8
|
|
9
9
|
RuboCop::Sorbet::Inject.defaults!
|
10
10
|
|
11
|
-
require_relative
|
11
|
+
require_relative "rubocop/cop/sorbet_cops"
|
data/manual/cops.md
CHANGED
@@ -7,20 +7,23 @@ In the following section you find all available cops:
|
|
7
7
|
|
8
8
|
* [Sorbet/AllowIncompatibleOverride](cops_sorbet.md#sorbetallowincompatibleoverride)
|
9
9
|
* [Sorbet/BindingConstantWithoutTypeAlias](cops_sorbet.md#sorbetbindingconstantwithouttypealias)
|
10
|
+
* [Sorbet/CallbackConditionalsBinding](cops_sorbet.md#sorbetcallbackconditionalsbinding)
|
10
11
|
* [Sorbet/CheckedTrueInSignature](cops_sorbet.md#sorbetcheckedtrueinsignature)
|
11
12
|
* [Sorbet/ConstantsFromStrings](cops_sorbet.md#sorbetconstantsfromstrings)
|
12
13
|
* [Sorbet/EnforceSigilOrder](cops_sorbet.md#sorbetenforcesigilorder)
|
13
14
|
* [Sorbet/EnforceSignatures](cops_sorbet.md#sorbetenforcesignatures)
|
15
|
+
* [Sorbet/EnforceSingleSigil](cops_sorbet.md#sorbetenforcesinglesigil)
|
14
16
|
* [Sorbet/FalseSigil](cops_sorbet.md#sorbetfalsesigil)
|
15
17
|
* [Sorbet/ForbidExtendTSigHelpersInShims](cops_sorbet.md#sorbetforbidextendtsighelpersinshims)
|
16
18
|
* [Sorbet/ForbidIncludeConstLiteral](cops_sorbet.md#sorbetforbidincludeconstliteral)
|
19
|
+
* [Sorbet/ForbidRBIOutsideOfAllowedPaths](cops_sorbet.md#sorbetforbidrbioutsideofallowedpaths)
|
17
20
|
* [Sorbet/ForbidSuperclassConstLiteral](cops_sorbet.md#sorbetforbidsuperclassconstliteral)
|
21
|
+
* [Sorbet/ForbidTUnsafe](cops_sorbet.md#sorbetforbidtunsafe)
|
18
22
|
* [Sorbet/ForbidUntypedStructProps](cops_sorbet.md#sorbetforbiduntypedstructprops)
|
19
23
|
* [Sorbet/HasSigil](cops_sorbet.md#sorbethassigil)
|
20
24
|
* [Sorbet/IgnoreSigil](cops_sorbet.md#sorbetignoresigil)
|
21
25
|
* [Sorbet/KeywordArgumentOrdering](cops_sorbet.md#sorbetkeywordargumentordering)
|
22
26
|
* [Sorbet/OneAncestorPerLine](cops_sorbet.md#sorbetoneancestorperline)
|
23
|
-
* [Sorbet/ParametersOrderingInSignature](cops_sorbet.md#sorbetparametersorderinginsignature)
|
24
27
|
* [Sorbet/SignatureBuildOrder](cops_sorbet.md#sorbetsignaturebuildorder)
|
25
28
|
* [Sorbet/SignatureCop](cops_sorbet.md#sorbetsignaturecop)
|
26
29
|
* [Sorbet/SingleLineRbiClassModuleDefinitions](cops_sorbet.md#sorbetsinglelinerbiclassmoduledefinitions)
|