rubocop-sorbet 0.6.7 → 0.6.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abb9e641bb3b12d53d9364cd235ab21b63c48339d2ffba858f593d421d029868
4
- data.tar.gz: 5e2758c93d99a35d2c93914bd3e2c2bba08de4770eb2519a6b9a938460cddd3e
3
+ metadata.gz: 64fed7c9d13d31d36b4291400c35f40857cd11522f877538aa4225bf0da1382b
4
+ data.tar.gz: f813a95fd882e1d51585cb1cffb79169f378d2a27ff5956b4a1f7b2f397e4f21
5
5
  SHA512:
6
- metadata.gz: d0ae42fc7fb217d55f94ed40dfe8d721c18666d9b5bfe5c87035694c978c4165a41089dac38db2594904befffb3c33c80d62f7fbee440bdcbfa3e1d1e9687bc3
7
- data.tar.gz: e418a1bdbdcd084c0ebe76a976ee813836be481fdfa336eb3387ab569adacabdd3bea6f9b9fefb74a9968bb56c8ad4a2ec1d5915b467626ecddb6a4904f1d738
6
+ metadata.gz: 5582a0d4b3e833504826549d967eded49aa32403741eea67af4a89dd3a95170164ae0ff540bc6f2422c9c34a82ceec281f991312c525937d956659773250f9ca
7
+ data.tar.gz: b3354da7079b05cfd16a541d25db45c271eb2dc43e1fae34dd336e38fca8b290ea8a58c643a178bebe722e2ed5b3d4f2f2d2096ad67ab943fdbae950a67f5f04
@@ -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 ]
14
+ ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ]
15
15
  name: Test Ruby ${{ matrix.ruby }}
16
16
  steps:
17
17
  - uses: actions/checkout@v2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.6.7)
4
+ rubocop-sorbet (0.6.8)
5
5
  rubocop (>= 0.90.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -60,13 +60,15 @@ end
60
60
 
61
61
  ### Rubocop rules for RBI files
62
62
 
63
- Put this into your `.rubocop.yml`:
63
+ To enable the cops related to RBI files under the `sorbet/rbi/` directory, put this in `sorbet/rbi/.rubocop.yml`:
64
64
 
65
65
  ```yaml
66
66
  inherit_gem:
67
67
  rubocop-sorbet: config/rbi.yml
68
68
  ```
69
69
 
70
+ This will turn off default cops for `**/*.rbi` files and enable the RBI specific cops.
71
+
70
72
  ## The Cops
71
73
  All cops are located under [`lib/rubocop/cop/sorbet`](lib/rubocop/cop/sorbet), and contain examples/documentation.
72
74
 
@@ -57,12 +57,18 @@ module RuboCop
57
57
  )
58
58
  PATTERN
59
59
 
60
- def_node_matcher(:generic_parameter_decl?, <<-PATTERN)
60
+ def_node_matcher(:generic_parameter_decl_call?, <<-PATTERN)
61
61
  (
62
62
  send nil? {:type_template :type_member} ...
63
63
  )
64
64
  PATTERN
65
65
 
66
+ def_node_matcher(:generic_parameter_decl_block_call?, <<-PATTERN)
67
+ (block
68
+ (send nil? {:type_template :type_member}) ...
69
+ )
70
+ PATTERN
71
+
66
72
  def_node_search(:method_needing_aliasing_on_t?, <<-PATTERN)
67
73
  (
68
74
  send
@@ -81,7 +87,7 @@ module RuboCop
81
87
  end
82
88
 
83
89
  def not_generic_parameter_decl?(node)
84
- !generic_parameter_decl?(node)
90
+ !generic_parameter_decl_call?(node) && !generic_parameter_decl_block_call?(node)
85
91
  end
86
92
 
87
93
  def not_nil?(node)
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubocop/cop/style/mutable_constant"
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module Sorbet
8
+ module MutableConstantSorbetAwareBehaviour
9
+ def self.prepended(base)
10
+ base.def_node_matcher(:t_let, <<~PATTERN)
11
+ (send (const nil? :T) :let $_constant _type)
12
+ PATTERN
13
+ end
14
+
15
+ def on_assignment(value)
16
+ t_let(value) do |constant|
17
+ value = constant
18
+ end
19
+
20
+ super(value)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ RuboCop::Cop::Style::MutableConstant.prepend(
28
+ RuboCop::Cop::Sorbet::MutableConstantSorbetAwareBehaviour
29
+ )
@@ -28,3 +28,5 @@ require_relative "sorbet/sigils/strict_sigil"
28
28
  require_relative "sorbet/sigils/strong_sigil"
29
29
  require_relative "sorbet/sigils/enforce_sigil_order"
30
30
  require_relative "sorbet/sigils/enforce_single_sigil"
31
+
32
+ require_relative "sorbet/mutable_constant_sorbet_aware_behaviour"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module RuboCop
3
3
  module Sorbet
4
- VERSION = "0.6.7"
4
+ VERSION = "0.6.8"
5
5
  end
6
6
  end
data/manual/cops.md CHANGED
@@ -34,3 +34,8 @@ In the following section you find all available cops:
34
34
  * [Sorbet/ValidSigil](cops_sorbet.md#sorbetvalidsigil)
35
35
 
36
36
  <!-- END_COP_LIST -->
37
+
38
+ In addition to the cops defined in this gem, it also modifies the behaviour of some other cops
39
+ defined in other RuboCop gems:
40
+
41
+ * [Style/MutableConstant](https://docs.rubocop.org/rubocop/cops_style.html#stylemutableconstant): In addition to the default behaviour, RuboCop Sorbet makes this cop `T.let` aware, so that `CONST = T.let([1, 2, 3], T::Array[Integer])` is also treated as a mutable literal constant value.
File without changes
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.7
4
+ version: 0.6.8
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: 2022-02-11 00:00:00.000000000 Z
14
+ date: 2022-04-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -92,6 +92,7 @@ files:
92
92
  - lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb
93
93
  - lib/rubocop/cop/sorbet/forbid_t_unsafe.rb
94
94
  - lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb
95
+ - lib/rubocop/cop/sorbet/mutable_constant_sorbet_aware_behaviour.rb
95
96
  - lib/rubocop/cop/sorbet/one_ancestor_per_line.rb
96
97
  - lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb
97
98
  - lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb
@@ -120,7 +121,7 @@ files:
120
121
  - manual/cops_sorbet.md
121
122
  - rubocop-sorbet.gemspec
122
123
  - service.yml
123
- - shipit.yml
124
+ - shipit.production.yml
124
125
  - tasks/cops_documentation.rake
125
126
  homepage: https://github.com/shopify/rubocop-sorbet
126
127
  licenses: