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
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.6.
|
4
|
+
version: 0.6.5
|
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: 2021-
|
14
|
+
date: 2021-12-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -31,30 +31,30 @@ dependencies:
|
|
31
31
|
name: unparser
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- - "
|
34
|
+
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '0'
|
36
|
+
version: '0.6'
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - "
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0'
|
43
|
+
version: '0.6'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: rubocop
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 0.90.0
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: 0.90.0
|
58
58
|
description:
|
59
59
|
email:
|
60
60
|
- ruby@shopify.com
|
@@ -64,12 +64,12 @@ extra_rdoc_files: []
|
|
64
64
|
files:
|
65
65
|
- ".github/CODEOWNERS"
|
66
66
|
- ".github/probots.yml"
|
67
|
+
- ".github/release.yml"
|
67
68
|
- ".github/stale.yml"
|
69
|
+
- ".github/workflows/ci.yml"
|
68
70
|
- ".gitignore"
|
69
71
|
- ".rspec"
|
70
72
|
- ".rubocop.yml"
|
71
|
-
- ".shopify-build/VERSION"
|
72
|
-
- ".shopify-build/rubocop-sorbet.yml"
|
73
73
|
- ".travis.yml"
|
74
74
|
- CODE_OF_CONDUCT.md
|
75
75
|
- Gemfile
|
@@ -79,18 +79,25 @@ files:
|
|
79
79
|
- Rakefile
|
80
80
|
- bin/console
|
81
81
|
- bin/rspec
|
82
|
+
- bin/rubocop
|
82
83
|
- bin/setup
|
83
84
|
- config/default.yml
|
85
|
+
- config/rbi.yml
|
84
86
|
- dev.yml
|
85
87
|
- lib/rubocop-sorbet.rb
|
86
88
|
- lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb
|
89
|
+
- lib/rubocop/cop/sorbet/callback_conditionals_binding.rb
|
87
90
|
- lib/rubocop/cop/sorbet/constants_from_strings.rb
|
88
|
-
- lib/rubocop/cop/sorbet/forbid_extend_t_sig_helpers_in_shims.rb
|
89
91
|
- lib/rubocop/cop/sorbet/forbid_include_const_literal.rb
|
90
92
|
- lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb
|
93
|
+
- lib/rubocop/cop/sorbet/forbid_t_unsafe.rb
|
91
94
|
- lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb
|
92
95
|
- lib/rubocop/cop/sorbet/one_ancestor_per_line.rb
|
96
|
+
- lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb
|
97
|
+
- lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb
|
98
|
+
- lib/rubocop/cop/sorbet/rbi/single_line_rbi_class_module_definitions.rb
|
93
99
|
- lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb
|
100
|
+
- lib/rubocop/cop/sorbet/sigils/enforce_single_sigil.rb
|
94
101
|
- lib/rubocop/cop/sorbet/sigils/false_sigil.rb
|
95
102
|
- lib/rubocop/cop/sorbet/sigils/has_sigil.rb
|
96
103
|
- lib/rubocop/cop/sorbet/sigils/ignore_sigil.rb
|
@@ -102,10 +109,8 @@ files:
|
|
102
109
|
- lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb
|
103
110
|
- lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb
|
104
111
|
- lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb
|
105
|
-
- lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb
|
106
112
|
- lib/rubocop/cop/sorbet/signatures/signature_build_order.rb
|
107
113
|
- lib/rubocop/cop/sorbet/signatures/signature_cop.rb
|
108
|
-
- lib/rubocop/cop/sorbet/single_line_rbi_class_module_definitions.rb
|
109
114
|
- lib/rubocop/cop/sorbet_cops.rb
|
110
115
|
- lib/rubocop/sorbet.rb
|
111
116
|
- lib/rubocop/sorbet/inject.rb
|
@@ -138,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
143
|
- !ruby/object:Gem::Version
|
139
144
|
version: '0'
|
140
145
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
146
|
+
rubygems_version: 3.2.20
|
142
147
|
signing_key:
|
143
148
|
specification_version: 4
|
144
149
|
summary: Automatic Sorbet code style checking tool.
|
data/.shopify-build/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
v1
|
@@ -1,16 +0,0 @@
|
|
1
|
-
containers:
|
2
|
-
default:
|
3
|
-
docker: "circleci/ruby:2.5.5"
|
4
|
-
|
5
|
-
steps:
|
6
|
-
- label: ":ruby: Specs"
|
7
|
-
dependencies:
|
8
|
-
- "bundler"
|
9
|
-
timeout: "5m"
|
10
|
-
run:
|
11
|
-
- "bundle exec rspec"
|
12
|
-
- label: "Rubocop"
|
13
|
-
dependencies:
|
14
|
-
- "bundler"
|
15
|
-
timeout: "5m"
|
16
|
-
run: "bundle exec rubocop"
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rubocop'
|
4
|
-
require_relative 'signature_cop'
|
5
|
-
|
6
|
-
module RuboCop
|
7
|
-
module Cop
|
8
|
-
module Sorbet
|
9
|
-
# This cop checks for inconsistent ordering of parameters between the
|
10
|
-
# signature and the method definition. The sorbet-runtime gem raises
|
11
|
-
# when such inconsistency occurs.
|
12
|
-
#
|
13
|
-
# @example
|
14
|
-
#
|
15
|
-
# # bad
|
16
|
-
# sig { params(a: Integer, b: String).void }
|
17
|
-
# def foo(b:, a:); end
|
18
|
-
#
|
19
|
-
# # good
|
20
|
-
# sig { params(a: Integer, b: String).void }
|
21
|
-
# def foo(a:, b:); end
|
22
|
-
class ParametersOrderingInSignature < SignatureCop
|
23
|
-
def_node_search(:signature_params, <<-PATTERN)
|
24
|
-
(send _ :params ...)
|
25
|
-
PATTERN
|
26
|
-
|
27
|
-
def on_signature(node)
|
28
|
-
sig_params = signature_params(node).first
|
29
|
-
|
30
|
-
sig_params_order = extract_parameters(sig_params)
|
31
|
-
return if sig_params_order.nil?
|
32
|
-
method_node = node.parent.children[node.sibling_index + 1]
|
33
|
-
return if method_node.nil? || method_node.type != :def
|
34
|
-
method_parameters = method_node.arguments
|
35
|
-
|
36
|
-
check_for_inconsistent_param_ordering(sig_params_order, method_parameters)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def extract_parameters(sig_params)
|
42
|
-
return [] if sig_params.nil?
|
43
|
-
|
44
|
-
arguments = sig_params.arguments.first
|
45
|
-
return arguments.keys.map(&:value) if RuboCop::AST::HashNode === arguments
|
46
|
-
|
47
|
-
add_offense(
|
48
|
-
sig_params,
|
49
|
-
message: "Invalid signature."
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
|
-
def check_for_inconsistent_param_ordering(sig_params_order, parameters)
|
54
|
-
parameters.each_with_index do |param, index|
|
55
|
-
param_name = param.children[0]
|
56
|
-
sig_param_name = sig_params_order[index]
|
57
|
-
|
58
|
-
next if param_name == sig_param_name
|
59
|
-
|
60
|
-
add_offense(
|
61
|
-
param,
|
62
|
-
message: "Inconsistent ordering of arguments at index #{index}. " \
|
63
|
-
"Expected `#{sig_param_name}` from sig above."
|
64
|
-
)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|